0

I have an image within a collection view that I am unable to click on. Appium can find the element fine but using the is_displayed() function always returns false. I read up on the iOS Class chain function so attempted to use that to click on the images parent XCUIElementTypeCell (Which can be clicked on, but has no label, or name value annoyingly)

My attempt:

self._driver.find_element(By.IOS_CLASS_CHAIN, "**/XCUIElementTypeImage[`name BEGINSWITH \"Click Me\"`]/**/XCUIElementTypeOther/**/XCUIElementTypeCell")

This gives a NoSuchElementException

The app structure looks like this: Screenshot of a sample of the app structure

So that XCUIElementTypeImage in the centre is what I am trying to target using name which equals "click me" in this example. The parent XCUIElementTypeOther also can be found but is not clickable so the only solution for me is jump up two levels to the XCUIElementTypeCell

P.S Please no Xpath suggestions

P.S2 Thanks for the help

Wasiq Bhamla
  • 949
  • 1
  • 7
  • 12
King
  • 827
  • 2
  • 10
  • 20
  • So, you want to go to the first XCUIElementTypeCell? Why don't you try this: **/XCUIElementTypeCollectionView/XCUIElementTypeCell[1]. AFAIK, we can't go to parent elements in ios Class Chain. – Ahamed Abdul Rahman Nov 28 '19 at 05:42

1 Answers1

0

Try the following:

"**/XCUIElementTypeCell[$type=XCUIElementTypeImage AND name BEGINSWITH 'Click Me'$]"

OR

"**/XCUIElementTypeCell[$type='XCUIElementTypeImage' AND name BEGINSWITH 'Click Me'$]"
  • Thanks I'll give it a go, what does the '$' sign refer to exactly? – King Nov 21 '18 at 09:16
  • Doesn't work, seems that it's picking up the internal element. I've managed to get it working by using an xpath command and adding "parent::XCUIElementTypeOther" on the end, so it's not too long – King Nov 23 '18 at 15:41
  • @Alesia D, I think you have to put type == 'XCUIElementTypeImage', instead of single equal symbol. – Ahamed Abdul Rahman Nov 28 '19 at 05:46
  • please help i am facing the same issue - in app structure it showing I have to click on XCUIElementType cell - the last element i copied – Aditi Jul 30 '20 at 10:23