Not able to findElement by any identifiers runtime

if i store all elements into a List using findElementsbyClass it finds, but performance is low, code given below.

  String value = "Smith, John";
  List<MobileElement> elements = iDriver.findElementsByClassName("XCUIElementTypeStaticText");
   for(MobileElement element : elements)
  {
        if ((element.getAttribute("name").toString.equalsIgnoreCase(value)))
           {
                 element.click();
          }
  } 

But I am not a able to find the element using the below code…

                        String value = "Smith, John";
                        iDriver.findElement(By.xpath("//XCUIElementTypeStaticText[@name='"+value+"']")).click();

Tried —
with
iDriver.findElement(By.id(value)))
iDriver.findElement(MobileFindBy.accessibilityId)))
wait.until(ExpectedConditions.visibilityOf(element))

No Luck.

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 5.23 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘unknown’, revision: ‘unknown’, time: 'unknown’
System info: host: ‘dhcp-10-176-250-54.in.oracle.com’, ip: ‘2606:b400:c10:4168:dde8:4cce:ea13:2e62’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.12.6’, java.version: '1.8.0_131’
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities [{app=/Users/xstoreisc/Documents/workspace/iOS_Android_Automation_v1.3//app//app.ipa, networkConnectionEnabled=false, noReset=true, xcodeOrgId=VYAKS7W7VC, databaseEnabled=false, deviceName=ios Device, updatedWDABundleId=ios.appium.WebDriverAgentRunner101, xcodeSigningId=iPhone Developer, platform=MAC, showXcodeLog=true, platformVersion=10.3, webStorageEnabled=false, locationContextEnabled=false, automationName=XCUITest, browserName=, takesScreenshot=true, javascriptEnabled=true, platformName=iOS, udid=a83748dksdhjfdjc02937237823kdwewhjw1}]
Session ID: 4c4bc848-9342-4da7-9283-25105af925e8
*** Element info: {Using=xpath, value=//XCUIElementTypeStaticText[@name=“Smith, John”]}
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:272)
at io.appium.java_client.DefaultGenericMobileElement.execute(DefaultGenericMobileElement.java:45)
at io.appium.java_client.MobileElement.execute(MobileElement.java:1)
at io.appium.java_client.ios.IOSElement.execute(IOSElement.java:1)
at org.openqa.selenium.remote.RemoteWebElement.findElement(RemoteWebElement.java:175)
at io.appium.java_client.DefaultGenericMobileElement.findElement(DefaultGenericMobileElement.java:65)
at io.appium.java_client.MobileElement.findElement(MobileElement.java:1)
at io.appium.java_client.ios.IOSElement.findElement(IOSElement.java:1)
at org.openqa.selenium.remote.RemoteWebElement.findElementById(RemoteWebElement.java:208)
at io.appium.java_client.DefaultGenericMobileElement.findElementById(DefaultGenericMobileElement.java:73)
at io.appium.java_client.MobileElement.findElementById(MobileElement.java:1)
at io.appium.java_client.ios.IOSElement.findElementById(IOSElement.java:1)
at org.openqa.selenium.By$ById.findElement(By.java:218)
at org.openqa.selenium.remote.RemoteWebElement.findElement(RemoteWebElement.java:171)
at io.appium.java_client.DefaultGenericMobileElement.findElement(DefaultGenericMobileElement.java:61)
at io.appium.java_client.MobileElement.findElement(MobileElement.java:1)
at io.appium.java_client.ios.IOSElement.findElement(IOSElement.java:1)
at io.appium.java_client.pagefactory.ElementInterceptor.getObject(ElementInterceptor.java:40)
at io.appium.java_client.pagefactory.interceptors.InterceptorOfASingleElement.intercept(InterceptorOfASingleElement.java:62)
at io.appium.java_client.ios.IOSElement$$EnhancerByCGLIB$$184e91dc.findElement()
at pageObjects.BasePage.selectListValueXpath(BasePage.java:745)
at pageObjects.LoginPage.selectAssociateFromList(LoginPage.java:557)
at testCases.AttachCustomerToTransaction.attachCustomerToTrans(AttachCustomerToTransaction.java:76)

@troyhugs you searching it wrong :slight_smile:. try:

String value = "Smith, John";
MobileElement element = (MobileElement) driver.findElement(MobileBy.iOSNsPredicateString("type == 'XCUIElementTypeStaticText' AND name == '" + value + "' AND visible == 1"));

@Aleksei - No luck :frowning:

@Aleksei
can you please send the syntax for using accessibility id by iOSNsPredicateString technic ?

@troyhugs can you give pageSource of screen when it happens?

@Aleksei

source.txt (38.6 KB)

@troyhugs try without visibility:

String value = "Smith, John";
MobileElement element = (MobileElement) driver.findElement(MobileBy.iOSNsPredicateString("type == 'XCUIElementTypeStaticText' AND name == '" + value + "'"));

also maybe …

String value = "Smith, John";
MobileElement element = (MobileElement) driver.findElement(MobileBy.iOSNsPredicateString("type == 'XCUIElementTypeStaticText' AND value == '" + value + "'"));

also when you executing this command after page loaded? do you check that your page loaded?

Page is loaded very much. Not luck with value as well.

can you please send the syntax for using accessibility id by iOSNsPredicateString technic ?

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 7.93 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘unknown’, revision: ‘unknown’, time: ‘unknown’
System info: host: ‘dhcp-10-176-250-54.in.oracle.com’, ip: ‘2606:b400:c10:4168:553b:ce5e:eff2:534c’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.12.6’, java.version: ‘1.8.0_131’
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities [{app=/Users/xstoreisc/Documents/workspace/Automation_v1.3//app//app.ipa, networkConnectionEnabled=false, noReset=true, xcodeOrgId=VYAKS7W7VC, databaseEnabled=false, deviceName=ios Device, updatedWDABundleId=ios.appium.WebDriverAgentRunner101, xcodeSigningId=iPhone Developer, platform=MAC, showXcodeLog=true, platformVersion=10.3, webStorageEnabled=false, locationContextEnabled=false, automationName=XCUITest, browserName=, takesScreenshot=true, javascriptEnabled=true, platformName=iOS, udid=a8adusdad7asdjasdls9dkda35455ffd}]
Session ID: 955c0597-7dbd-47b4-bf97-6788362606e1
*** Element info: {Using=-ios predicate string, value=type == ‘XCUIElementTypeStaticText’ AND value == ‘Smith, John’}
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:410)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.findElement(IOSDriver.java:1)
at io.appium.java_client.FindsByIosNSPredicate.findElementByIosNsPredicate(FindsByIosNSPredicate.java:26)
at io.appium.java_client.MobileBy$ByIosNsPredicate.findElement(MobileBy.java:400)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:402)
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.ios.IOSDriver.findElement(IOSDriver.java:1)
at pageObjects.BasePage.selectListValueXpath(BasePage.java:744)
at pageObjects.LoginPage.selectAssociateFromList(LoginPage.java:557)
at testCases.AttachCustomerToTransaction.attachCustomerToTrans(AttachCustomerToTransaction.java:76)

@troyhugs for predicate staff - https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/ios_predicate.md

Page is loaded very much - Maybe timeout too small? Can you make simple test.

  1. open this page
  2. wait 20sec
  3. now try to find your “Agent Smith” :slight_smile:

@Aleksei

NoLuck on that too… I am not sure why this is happening.

anyways i got a work around but that is too bad in the performance. :frowning:

List elements = FindelementsbyClass(“XCUIElementTypeStaticText”);
and find elements by the getAttribute “name” method… but i know this is not the right way… also let me know if you get any clue on this.