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’])]