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


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

I switched the context using


But both of them didn’t work.

Any help around this is really appreciated.


Change it to be:


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


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.


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.


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.


Any help around this issue would be greatly appreciated .