I am writing a testcase where if a certain link is clicked a "Open xdg-open" Popup is triggered in the chrome browser.
I want to verify in my testcase if an "Open xdg-open" Popup actually appears.
I tried to use the following Code block:
boolean check;
try {
driver.switchTo().alert();
check = true;
} catch(NoAlertPresentException e) {
check = false;
}
However the "Open xdg-open" Popup triggers the NoAlertPresentExcpetion even though it appears in the browser.
Do you have any clue how I can verify the "Open xdg-open" Popup?
It does not work because it's not a DOM element you can switch to it. This kind of xdg-open
alert happens whenever it wants to handle a protocol defined by user preferences. It could be any of (afp, Tel, disk, file, hcp, ...)
You can use ChromeOptions
in order to exclude these kind of schemes
chrome_options.add_experimental_option( "prefs", {'protocol_handler.excluded_schemes.hcp': false})
You should change the protocol above with whatever protocol is on your side or use this code which exclude list of schemes
driver.execute_script("window.confirm = function(msg) { return true; }")
prefs = {"protocol_handler.excluded_schemes":{"afp":True,"data":True,"disk":True,"disks":True,"file":True,"hcp":True,"intent":True, "itms-appss":True, "itms-apps":True,"itms":True,"market":True,"javascript":True,"mailto":True,"ms-help":True,"news":True,"nntp":True,"shell":True,"sip":True,"snews":False,"vbscript":True,"view-source":True,"vnd":{"ms":{"radio":True}}}}
chrome_options.add_experimental_option("prefs",prefs)