For some reason, appium is not able to find an Android element using a full xpath. I’m using PageObjects and the PageObjectFactory. Any ideas? Here is the element in the page:
/**
* Mobile object - shoppingListMenuDrawerButton - Menu drawer button for shopping list
*
**/
@AndroidFindBy (xpath = "//*[text()='Shopping List']/..")
@iOSFindBy (xpath = "//*[@label='Lists']")
private WebElement shoppingListMenuDrawerButton;
Here is the code:
WebDriverWait wait = new WebDriverWait(wDriver, 50);
wait.until(ExpectedConditions.elementToBeClickable(shoppingListMenuDrawerButton));
Here is the error:
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: Located by Locator map:
-
native content: “By.chained({By.xpath: //*[text()=‘Shopping List’]/…})”
-
html content: “by id or name “shoppingListMenuDrawerButton”” (tried for 50 second(s) with 500 MILLISECONDS interval)
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:82)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:231)
at pageobjects.MenuDrawerPage.IsLoaded(MenuDrawerPage.java:162)
at tests.MenuDrawerPageTest.ClickMenuDrawerTest(MenuDrawerPageTest.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
Caused by: org.openqa.selenium.NoSuchElementException: Can’t locate an element by this strategy: Locator map:
-
native content: “By.chained({By.xpath: //*[text()=‘Shopping List’]/…})”
-
html content: "by id or name “shoppingListMenuDrawerButton”"
at io.appium.java_client.pagefactory.AppiumElementLocator.findElement(AppiumElementLocator.java:102)
at io.appium.java_client.pagefactory.interceptors.InterceptorOfASingleElement.intercept(InterceptorOfASingleElement.java:61)
at io.appium.java_client.android.AndroidElement$$EnhancerByCGLIB$$b598166c.isDisplayed()
at org.openqa.selenium.support.ui.ExpectedConditions.elementIfVisible(ExpectedConditions.java:301)
at org.openqa.selenium.support.ui.ExpectedConditions.access$100(ExpectedConditions.java:43)
at org.openqa.selenium.support.ui.ExpectedConditions$10.apply(ExpectedConditions.java:287)
at org.openqa.selenium.support.ui.ExpectedConditions$10.apply(ExpectedConditions.java:284)
at org.openqa.selenium.support.ui.ExpectedConditions$23.apply(ExpectedConditions.java:672)
at org.openqa.selenium.support.ui.ExpectedConditions$23.apply(ExpectedConditions.java:668)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
… 26 more
Caused by: org.openqa.selenium.TimeoutException: Expected condition failed: waiting for io.appium.java_client.pagefactory.AppiumElementLocator$WaitingFunction@7fd4acee (tried for 1 second(s) with 500 MILLISECONDS interval)
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:263)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:231)
at io.appium.java_client.pagefactory.AppiumElementLocator.waitFor(AppiumElementLocator.java:76)
at io.appium.java_client.pagefactory.AppiumElementLocator.findElement(AppiumElementLocator.java:95)
… 35 more
Caused by: org.openqa.selenium.NoSuchElementException: Cannot locate an element using By.chained({By.xpath: //*[text()=‘Shopping List’]/…})
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: '2017-11-06T21:01:39.354Z’
System info: host: ‘L7EIS-DEV504’, ip: ‘169.254.183.157’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: '1.8.0_152’
Driver info: driver.version: AndroidDriver
at io.appium.java_client.pagefactory.bys.builder.ByChained.findElement(ByChained.java:72)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:362)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at io.appium.java_client.pagefactory.bys.ContentMappedBy.findElement(ContentMappedBy.java:36)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:362)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at io.appium.java_client.pagefactory.AppiumElementLocator.lambda$0(AppiumElementLocator.java:96)
at io.appium.java_client.pagefactory.AppiumElementLocator$WaitingFunction.apply(AppiumElementLocator.java:150)
at io.appium.java_client.pagefactory.AppiumElementLocator$WaitingFunction.apply(AppiumElementLocator.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
… 37 more