Any sample project / tutorial with how to use XCUI Elements for Native IOS APP


#1

Hi All,

I have started my first automation project using Cucumber/Selenium 3.4 with Appium 1.6.5 and iOS version 10.2.

I am able to launch the iOS app perfectly, but I am unable to interact with any elements.
for example, when the app launches, there a table with multiple values on the app page.
the Element is identified as

I have tried
driver.findElement(By.xpath("//XCUIElementTypeStaticText[@name=‘City’]"))
Didnt work

I tried with table head
and its xpath is

//XCUIElementTypeApplication[@name=“CityNames”]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable

driver.findElements(By.xpath("//XCUIElementTypeStaticText[@name=‘CityNames’]"))
to get all the elements of the table.

However i get the error
NoSuchSessionExeption
And the message is
A session is either terminated or not started


#2

@rahulk

driver.findElement(MobileBy.className("XCUIElementTypePickerWheel")).sendKeys("some_text"); 
((IOSDriver) driver).findElementsByIosNsPredicate("value = '" + descr + "'") // value is Text to search
driver.findElement(MobileBy.iOSNsPredicateString("type == 'XCUIElementTypeStaticText' AND name == '" + name + "' AND visible == 1")) // name is ID in most cases

#3

Thanks ! The following worked for me:

driver.findElement(MobileBy.iOSNsPredicateString(“type == ‘XCUIElementTypeStaticText’ AND name == '” + name + “’ AND visible == 1”)) // name is ID in most cases


#4

I am not able to send keys to XCUIElementTypePickerWheel …


#5

I did a workaround by implementing a script, that scrolls manually and compares element values to the one I’m looking for.