How to accept warning 'this type of file can harm your device'?

Hi,

I am using chrome browser in android. As part of the scenario if I click on a link I am getting warning ‘This type of file can harm your device’.Do you want to keep xxxx.apk file anyway ?

How to click OK using APPIUM?

Appium version : 1.2.4
Android version : 4.4.4
Device : Nexus 7

I tried driver.getContextHandles(); to see the contexts and I found there are 2 viz WEBVIEW_1 & NATIVE_APP

Try1:
I switched the context using
driver.context(“NATIVE_APP”);
driver.findElementByAndroidUIAutomator(“UiSelector().resourceIdMatches("button_primary")”).click();

Try2:
driver.context(“NATIVE_APP”).switchTo().alert().accept();

But both of them didn’t work.

Any help around this is really appreciated.

Thanks,
Raghavendra

Change it to be:

driver.context(“WEBVIEW_1”).switchTo().alert().accept();

I get an error stating 'org.openqa.selenium.NoAlertPresentException: no alert open ’ when I use the line

driver.context(“WEBVIEW_1”).switchTo().alert().accept();

Then it’t not an alert.

Try to inspect using Chrome remote debugging and make sure that there is only one webview context as you think as I suspect there is two webview contexts.

@Hassan_Radi,

I did try debugging using inspect, but then I could only see the page in mobile chrome and not the confirmation bar. And getContextHandles() shows NATIVE_APP and WEBVIEW_1.

When you debugged using Chrome remote debugging the message didn’t appear??

Try to reset the browser before you open the remote debugged to simulate what Appium actually does at the session start.

Hi this quite new approach, so since you are testing mobile site. you can record mobile site in your browser using selenium IDE. and trust me all locators will work… so just add user agent to ur firefox. that enable mobile site to ur firefox browser.

@Priyank_Shah,

I tried recording scenario using Selenium IDE , however when I click on the link it pops up dialog asking me to save the .apk file which we can not record in selenium IDE.

@jlipps,

Any help around this issue would be greatly appreciated .

Thanks,
Raghavendra