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
• 16,450 points
24 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,030 points
1,160 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
100 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
586 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
36 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,030 points
72 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
444 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
55 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
468 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.