Click on element in alert - ios 15

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:

public boolean clickInAlertElement(By elem) {
        return true;
     } catch (Throwable t) {
          return false;

also I tried to driver.SwitchTo().Alert().getText(); and I son’t get the text at all

  • java
  • ios 15.1
  • real device

What does this look like in Appium Inspector? If it’s really an alert, you’ll see this type, “XCUIElementTypeAlert” in the xml.

here is it


Are you sure that’s the right xml? I don’t see an alert element, first of all, but second there is no “Call 9-11”, instead I see this:

                                        <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Call 166" name="Call 166" label="Call 166" enabled="true" visible="true" accessible="true" x="84" y="671" width="267" height="24" index="2"/>

What is “Call 166”?

@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')]

Yes, The 166 same as the 911

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.

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?

Here is the documentation on find_element:

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?

Yes, from the information that I have that seems like the logical conclusion.

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"));

Thank you, tried them both (each) and they are not work maybe I missed something?

sounds not clear. element not found or ? tried add simple sleep before (cause this driver.findElement is quite fast check)?

try add logs like:

System.out.println(el.getLocation().x, el.getLocation().y); 

Just opened the Appium inspector and search with it the elements according to iOSNsPredicateString

i do not use Appium inspector. try on code.

`WebElement el2 = getDriver().findElement(MobileBy.iOSNsPredicateString(“type == ‘XCUIElementTypeButton’ AND name CONTAINS[cd] ‘Call’ AND visible == 1”));;`

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.

in debug mode

all 3 examples?
write after error happen get:


and write here pageSource at moment of fail.

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

we will not understand until you get page source at moment of fail