Hello,
In my real device ios 15.1 I have scenario where I should click on “call…” in popup (Alert), I have tried to use the method to wait for the alert and than click on the element and still it fall where it needs to wait (even for 1 min), the code looks like that:
@wreed yes thats the right one, it looks like that apple change something and it is not Alert anymore, I saw it yesterday too and open that XML in chrome and look for that in xpath (thats what I suppose to do?) and saw that it is not alert and didn’t obtain something that worked at the code actualy.
I tried //XCUIElementTypeStaticText[contains(text(), 'Call')]
I don’t use xpath on iOS because it’s too slow, but I know sometimes you can’t avoid it. I don’t know the language you are using but I’d do something like this in Ruby:
driver.find_element(:name, 'Call')
I’m sure there is something similar in whatever you are using.
@wreed
So i’m using Java
And there is 2 items on “Call” over there… your method found one?
And still, it is not overlay or something like these? how it will manage to click on it?
I obviously can’t code against your app as I don’t have it. But this is why I wanted you to take a look with Appium Inspector. The inspector will give you a lot more information that just the XML, and should help you to see how to access this element.
@wreed Thank you, obviously I used the inspector, but as far as I tried with the alert element it didn’t worked (it worked till version 15 of IOS) so maybe it was changed and now I just need to click on it like regular element eventough it is look like alert?
@wreed
I tried to search for the element and to click on it, when I click on it, it disappear (the two lines), when I click again on the call (The orange one) It calling
the locator is: //XCUIElementTypeStaticText[contains(@name,"Call")]
what I missing here? (manually it works ok)
// java examples
// el1 and el11 -> find element with text = 'Call 166'. difference with additional condition of 'type'
WebElement el1 = driver.findElement(MobileBy.iOSNsPredicateString("type == 'XCUIElementTypeButton' AND name == 'Call 166' AND visible == 1"));
WebElement el11 = driver.findElement(MobileBy.iOSNsPredicateString("name == 'Call 166' AND visible == 1"));
// el2 -> find element with text contains 'Call'
WebElement el2 = driver.findElement(MobileBy.iOSNsPredicateString("type == 'XCUIElementTypeButton' AND name CONTAINS[cd] 'Call' AND visible == 1"));
so
`WebElement el2 = getDriver().findElement(MobileBy.iOSNsPredicateString(“type == ‘XCUIElementTypeButton’ AND name CONTAINS[cd] ‘Call’ AND visible == 1”));
el2.click();`
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
I’m using the 3rd example since I don’t want to work on just “166”, and page source right away isn’t go since
WebElement el2 = getDriver().findElement(MobileBy.iOSNsPredicateString("type == 'XCUIElementTypeButton' AND name CONTAINS[cd] 'Call' AND visible == 1"));
is failed the test