python selenium execute script confirmation box, getting results back

33 views Asked by At

When running a scraping tool I am in the process of writing I need to interact with the user but prefer not via the console as that means switching between the console and the browser.

Problem is I can't figure out how to get the results, for example:

r = self.driver.execute_script('return confirm("test press ok or cancel");')

results in none, either when I press ok or cancel. I've first had to wait until the alert pops up then wait again until I get NoAlertPresentException using the usal try/except with

alert = self.driver.switch_to.alert

and carrying on until I hit the NoAlertPresentException. Now the question is does doing alert = .... nuke the

r = self.driver.execute_script 

by any chance if thats the case how do I get the value of a python selenium script created alert and is it even possible ?

0

There are 0 answers