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

0 votes
May 27, 2019 in Selenium by Sudha
1,021 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, 2019 by George

Related Questions In Selenium

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

How can I handle Javascript Alert popup using Ruby Selenium webdriver?

Hey Usman, you can use driver.switch_to.alert method ...READ MORE

answered Aug 26, 2019 in Selenium by Abha
• 27,720 points
148 views
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,510 points
5,657 views
0 votes
1 answer

Installing Selenium Webdriver with Python package

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

answered May 8, 2019 in Selenium by Anvi
• 14,010 points
387 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,510 points
1,514 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,850 points
1,477 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, 2019 in Selenium by Abha
• 27,720 points
255 views
0 votes
1 answer

How can I locate web elements from a web page using Selenium Webdriver?

Hey @Dushyant, Locating elements in WebDriver is ...READ MORE

answered May 28, 2019 in Selenium by Shreya
281 views