Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Wait for user to click on alert dialog box in python

I have created a dialog box in browser (this Happens when an error occurs in user input details). What I need is to wait until the user clicks on the dialog box before preceding with automatic execution (only for testing). Here is what I have

# driver is a chrome web driver
driver.execute_script("alert('qwer');")
wait = WebDriverWait(driver, 10)    
element = wait.until(EC.alert_is_present()) 

I tried to search online but only got an answer when a user clicks on a button inside a webpage but not on a generated dialog box. How to do it (if possible)?

like image 567
mj1261829 Avatar asked May 26 '19 14:05

mj1261829


1 Answers

from time import sleep
while EC.alert_is_present()(driver):
    sleep(30)

If you simply want to alert the user then use pymsgbox or Telegram API to send him a message,

from pymsgbox import alert
alert("Hey User")
like image 54
Smart Manoj Avatar answered Nov 12 '22 01:11

Smart Manoj