Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findElements method throws exception #26

Open
pranavkhare opened this issue Aug 9, 2016 · 3 comments
Open

findElements method throws exception #26

pranavkhare opened this issue Aug 9, 2016 · 3 comments

Comments

@pranavkhare
Copy link

pranavkhare commented Aug 9, 2016

Sometimes findelements method throws this error

An exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.Support.dll but was not handled in user code

Additional information: Unexpected error. System.Windows.Automation.ElementNotAvailableException: Element not available ---> System.Runtime.InteropServices.COMException: Operation timed out. (Exception from HRESULT: 0x80131505)

   at UIAutomationClient.IUIAutomationTreeWalker.GetFirstChildElementBuildCache(IUIAutomationElement element, IUIAutomationCacheRequest cacheRequest)

   at System.Windows.Automation.TreeWalker.GetFirstChild(AutomationElement element, CacheRequest request)

   --- End of inner exception stack trace ---

   at System.Windows.Automation.TreeWalker.GetFirstChild(AutomationElement element, CacheRequest request)

   at System.Windows.Automation.TreeWalker.GetFirstChild(AutomationElement element)

   at Winium.StoreApps.CodedUITestProject.WiniumElement.<IterFind>d__13.MoveNext()

   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()

   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)

   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

   at Winium.StoreApps.CodedUITestProject.ElementsRegistry.FindElements(WiniumElement root, By strategy)

   at Winium.StoreApps.CodedUITestProject.CommandExecutors.FindElementsExecutor.DoImpl()

   at Winium.StoreApps.CodedUITestProject.CommandExecutors.CommandExecutorBase.Do()
@NickAb
Copy link
Contributor

NickAb commented Aug 15, 2016

What type of locator do you use with findElements? Are you searching by class or name? Is your visual tree big (how many elements does it have)?

@pranavkhare
Copy link
Author

I am searching by by id. I am implementing to wait until the next page of the app loads. The code fires the command 'findElements' until the next page loads and it finds the element, after which it fires 'isElementDisplayed' command. This seems to work for shorter waits. For longer waits, after some time it throws

Additional information: Unexpected error. System.Windows.Automation.ElementNotAvailableException: Element not available ---> System.Runtime.InteropServices.COMException: Operation timed out. (Exception from HRESULT: 0x80131505)

@NickAb
Copy link
Contributor

NickAb commented Aug 16, 2016

This seems to be related to the fact, that elements becomes unavailable while the command is iterating tree, possible due to being called at same time as the transition occurs. What happens in the app at that moment, do you see app UI transitioning into new state? Are you calling isElementDisplayed on all found elements? If you are searching by id, then why do you use findElements and not findElement?

Meanwhile, as a workaround you can try adding exception being thrown to the list of exceptions ignored by WebDriver Wait. In case of java, see https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/FluentWait.html#ignoring-java.lang.Class- for reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants