How to find alert dialog through selenium using Appium?

The dialog is implemented in this way in the application:

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Something");
builder.setTitle("Something");
dialog = builder.create();
dialog.show();

How can I find this element in testing Appium script?

driver.switchTo().alert(); throws NotImplementError

driver.findElement(By.tagName("AlertDialog")) does not work

And I found this problem NYI Warning Methods on Github. Is there a workaround for this?

By the way, I will not click “OK” or “Cancel” in this dialog box, I am going to wait until this dialog box disappears automatically.

Thanks in advance.

+3
source share
3 answers

Please use the code below for your needs:

Waiting for a warning:

wait.until(ExpectedConditions.alertIsPresent());

Waiting for warning to disappear:

wait.until(!ExpectedConditions.alertIsPresent());
+3
source

, :

wait.until(ExpectedConditions.not(ExpectedConditions.alertIsPresent()));
+1

For me it works when I do this to accept a warning dialog with OK button

driver.findElement(By.name("OK")).click()

But after the click action is complete, my program stops detecting elements

0
source

All Articles