I am using C# Client to test an android app. Appium version: 1.13
I came across a situation wherein I was using the below piece of code to explicitly wait for an element to get displayed and it didn't work.
new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(d => driver.FindElement(new ByAndroidUIAutomator("text(\"Test\")")).Displayed);
whereas, the Appium driver waited for 10 seconds when I had changed the locator from ByAndroidUIAutomator to By.Xpath
new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(d => driver.FindElement(By.XPath("//*[@text='Test']")).Displayed);
To my surprise, ByAndroidUIAutomator waited for 5 seconds when I had used Implicit wait.
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
Now I am curious to know as to why it worked for the Implicit wait and not for the explicit wait.
Error Message when I used explicit wait is as follows:
Message: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ----> OpenQA.Selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
I don't think your usage of the ByAndroidUIAutomator
is correct. My expectation is that you should amend it to instantiate the appropriate UISelector like:
new ByAndroidUIAutomator("new UISelector().text(\"Test\")");
References:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.