Unable to tap an iOS app's element when it doesn't have either label or name object properties

KS 6.3.2 is able to tap on an element that contains label or name object properties. However, the application that I have under test has an element which is a button and does not contain either label or name or any text. Furthermore, the xpath of that element is dynamic.

The following are the snapshots of the Object’s properties of the same element of an application captured from 2 different devices:

The following is the Selected Locator’s value:

My Page 1:
//XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther[1]/XCUIElementTypeTabBar[1]/XCUIElementTypeButton[6][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘160.0’ and @x = ‘664.0’ and @y = ‘1628.0’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘160.0’ and @x = ‘664.0’ and @y = ‘1628.0’])]

My Page 2:
//XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeTabBar[1]/XCUIElementTypeButton[6][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘142.0’ and @x = ‘604.0’ and @y = ‘1238.0’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’ and @height = ‘96.0’ and @visible = ‘true’ and @width = ‘142.0’ and @x = ‘604.0’ and @y = ‘1238.0’])]

As you can see above that the following object properties values are not static:
width
x
y
xpath

However, the xpath’s starts-with and ends-with values are more or less constant.
xpath constant starts-with value is: //XCUIElementTypeApplication/XCUIElementTypeWindow[1]
xpath constant ends-with value is: /XCUIElementTypeTabBar[1]/XCUIElementTypeButton[6]

I have tried with xpath starts-with and ends-with values but it didn’t work. So any suggestion will be highly appreciated.

xpath ends-with selected locators value:
/XCUIElementTypeTabBar[1]/XCUIElementTypeButton[6][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’])]

xpath starts-with selected locators value:
//XCUIElementTypeApplication/XCUIElementTypeWindow[1][count(. | //[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’]) = count(//[@type = ‘XCUIElementTypeButton’ and @enabled = ‘true’])]

@duyluong @Russ_Thomas @Chris_Trevarthen

1 Like

After some digging and research, I found the following methods to solve my problem:

  1. With the help of appium-desktop, I was able to get the (x,y) co-ordinates of the element. Then in KS, I used the method called tapAtPosition(x,y) to tap at the icon. However, this is not the final way I ended up using because the co-ordinates changed with different size devices.

  2. I ended up creating a relative xpath for the element using KS spy mobile. This was my final relative xpath for the element: //*/XCUIElementTypeButton[6]