This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
20 / 21
Nov 2018

Hi @PavithraRavichandran,

You might have to inpsect the alert/pop up using Appium Inspector and get details about it. As for example in our app, an alert text comes up as a TextView object. Also, you might have to check if these alerts are displayed under native context. Could you give more details if your app is a native one or hybrid?

Thanks,
Sujata

Hi @sujata_kalluri,

Thanks for your reply, our app is native one and it was my problem I did a mistake in my code that's y it didn't work for me, now it's working or me. So, here in Android don't we want to switch to alert or is alert is not there in Appium ?

Thanks for your reply on time :smile: @sujata_kalluri

1 month later

Hi Pavitra,

I am getting the same error "not yet implemented " when trying to accept an alert using
Alert alert = driver.switchto().alert
alert.accept();

Can you please tell me how you handled this scenario?

Thanks,
Rohan

Hello Rohan,

In case you are trying to interact with native app alert, you do not need to switch to alert.
Just find the element on the alert as you find other elements and perform action. It is working fine for me.
e.g. to click on OK button of alert in my AUT:
driver.findElement(By.id("android:id/ok_button")).click();

Hope this helps.

Thanks,
Shanky

9 months later

It is not working for me driver.findElement(By.id("android:id/ok_button")).click();
and I am not able to find resource id of that pop up, what to do. please help me out.

22 days later

Hey @ajai2608 if you can get any other webelement please get that (id or any other) and use driver.findElement(By.()).click();.
It should work.

Thank you,
Pavithra

4 months later

Some alerts from the native apps can be identified by the inspector, but there are some which are not identified, like I am using selendroid sample app, where after clicking the "Display popup window" button, alert pops up, but can not be identified by uiautomator, any suggestions on this? thanks!

3 months later
2 months later
6 months later

Hello @sunilpatro1985, I am having the same problem with alert. Have you found any solution? How to work with this Poopup Window in selendroid app. I added capabilities.setCapability("autoAcceptAlerts", true); and used
Alert alert = driver.switchTo().alert();
// alert.accept();
alert.dismiss();
Error message appears
org.openqa.selenium.WebDriverException: Method has not yet been implemented
Thanks!

I've managed to figure out a workaround for my popup windows. In my case I had to navigate through contextMenu (android.widget.menu and .item) layout, which spawned AlertDialogLayout.

The trick is that that popup windows gets focused, meaning you can still send keyboard input. I've used TAB / DPAD keys to navigate around and ENTER to click on specific View. For example:

// Navigate to 1st item
driver.pressKeyCode(AndroidKeyCode.KEYCODE_DPAD_DOWN);
// Click the current item
driver.pressKeyCode(AndroidKeyCode.ENTER);

1 month later

How to handle your code with 2 buttons on pop-up
and in AndroidKeyCode.KEYCODE_DPAD_DOWN
what is KEYCODE_DPAD_DOWN ?
Can u plz explain a litl bit

3 months later

Simple take the path of the alert buttons.If you want to accept then take the xpth for accept .for dismiss take the path of dissmis button and click.Use the below cmd
driver.findElement(By.xpath("")).click.

25 days later
2 months later

you are testing of native application so you can try this code this is working for me

//click for showing pop up
RecentLocationHomeSelector.click();
WebDriverWait wait = new WebDriverWait(driver, 5);
// get the element of ok button
WebElement positiveButtonElementById=driver.findElement(By.id(“com.fittingnzidd.cherripik.development:id/positiveButton”));
//click on Ok button
positiveButtonElementById.click();

6 months later

Yeah, I had the same problem and got me crazy until i decided to check if the alert is shown by looking for tittle and button label patterns.
I dont think its the best scenario for this, doesnt look “safe” to build tests around elements with id like “button1”, but i guess its the only option for now.

1 month later

Hi,

Can Some one please tell me when the app launch it shows the sing in pop for few seconds then it shows the login page.
But in Appium inspector it shows the sing in elements And in device it shows the login page.

How should i handle the sing in alert

When i perform the steps using Appium inspector it doesnt shows the elements for that

Thnks
Chetan

1 month later

Hi,
I have the same issue about not being able to select alerts on different Android fragments. Can you please specify a method other than below?

  1. driver.switchTo().alert();
  2. driver.elementByXPath
  3. driver.elementById

I tried all of these options and still did not get a result in the following structure:

<android.widget.FrameLayout>
<android.widget.LinearLayout>
	<android.widget.FrameLayout resource-id="android:id/content">
		<android.widget.LinearLayout>
			<android.widget.ImageView resource-id="xx/iv_custom_alert_icon">
			<android.widget.TextView resource-id="xx/tv_custom_alert_title">
			<android.widget.TextView resource-id="xx/tv_custom_alert_subtitle">
		<android.widget.LinearLayout>
			<android.widget.TextView resource-id="xx/v_custom_alert_positive"> 

alternative suggestions would be appreciated, thanks.