How can I handle a Confirmation Alert pop-up using Python Webdriver?

0 votes
May 27 in Selenium by Sudha
129 views

1 answer to this question.

0 votes

Hey Sudha, you can use following code to handle confirmation alert popup using Python webdriver:

from selenium import webdriver
import time

driver = webdriver.Firefox()
driver.maximize_window()
driver.get(url)

#Switch the control to the Alert window
obj = driver.switch_to.alert

#Retrieve the message on the Alert window
message=obj.text
print ("Alert shows following message: "+ message )

time.sleep(2)

#use the accept() method to accept the alert
obj.accept()

# Or Dismiss the Alert using
obj.dismiss()

driver.close
answered May 27 by George

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to handle Pop-up in Selenium WebDriver using Java

Actually, its pretty simple. Use this code ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,050 points
3,890 views
0 votes
1 answer
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8 in Selenium by Anvi
• 11,890 points
109 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
427 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
781 views
0 votes
1 answer

How can I send some data to a Prompt Alert box using Selenium Webdriver?

Hey Abhishek, you can use sendKeys() method ...READ MORE

answered Jul 2 in Selenium by Abha
• 19,680 points
42 views
0 votes
1 answer