Selenium WebDriver 2 4 0 alert checking

0 votes

Before using Selenium WebDriver version 2.4.0, I used to follow the below code:

alert = page.driver.browser.switch_to.alert
if alert.text
  ....

But, Selenium 2.4.0 has changed  "Raise in switch_to.alert when no alert is present.", so I found an Error:

 No alert is present (Selenium::WebDriver::Error::NoAlertOpenError) exception.

How to check for the presence of an alert using selenium-web-driver 2.4.0?

Jun 1, 2018 in Selenium by Perry
• 17,100 points
620 views

1 answer to this question.

0 votes

You can go for the below option:

driver.switch_to.alert.accept rescue Selenium::WebDriver::Error::NoAlertOpenError

This will click OK on the alert if present, else it will fail silently.

answered Jun 1, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

0 votes
1 answer

How to use FireFoxDriver using Selenium 3.4.0 using Maven?

Your using the wrong functions to set ...READ MORE

answered Apr 6, 2018 in Selenium by nsv999
• 5,500 points
4,988 views
0 votes
1 answer

geckodriver in selenium webdriver 3.0 beta

Check this out System.setProperty("webdriver.gecko.driver", "pathTogeckodriver"); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("marionette", ...READ MORE

answered Apr 9, 2018 in Selenium by Christine
• 15,790 points
762 views
0 votes
1 answer

Handling JavaScript Alert window in Selenium WebDriver

You should try using waits for alerts ...READ MORE

answered Apr 10, 2018 in Selenium by ghost
• 1,790 points
2,446 views
0 votes
1 answer

Browser supported by Selenium 2.0

Below Will help you: Opera: The OperaDriver supports Opera ...READ MORE

answered Apr 20, 2018 in Selenium by Vardy
• 2,360 points
745 views
0 votes
2 answers

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,500 points
13,649 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,131 views
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,910 points
7,209 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,865 views
0 votes
1 answer

Which Firefox version is compatible with Selenium 2.53.0?

I had the similar problem. For me, ...READ MORE

answered Jun 26, 2018 in Selenium by Meci Matt
• 9,460 points
2,098 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP