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,010 points
34 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,400 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 5, 2018 in Selenium by nsv999
• 5,050 points
1,357 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
111 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
704 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,280 points
40 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
280 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
641 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
269 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,400 points
610 views