PhantomJS, Python, Selenium, Java notifications and popups, how to confirm?
When dealing with Java alerts/notifications that you need to accept and using a headless browser such as PhantomJS, there is no method (currently) for handling the alerts. Instead what you have to do is send a driver.execute script into the mix.
Example, in CUCM you have certain actions that create two consecutive pop-ups that you need to accept or press 'OK' on. For this you would need to do the following:
driver.execute_script("window.confirm = function(msg) { return true; }");
However, this simply cannot be placed after the pop up occurs, it must be pushed before the step you will use in Selenium that causes the pop up notification.Example, in CUCM you have certain actions that create two consecutive pop-ups that you need to accept or press 'OK' on. For this you would need to do the following:
try:
driver.execute_script("window.confirm = function(msg) { return true; }");
driver.execute_script("window.confirm = function(msg) { return true; }");
elem = driver.find_element_by_name("button2")
elem.click()
Comments
Post a Comment