How do you handle Alerts and Pop Ups?

Answer Posted / annasaheb

To Handle Alert

Alert alert = driver.switchTo().alert();
message = alert.getText();
alert.accept();//to accept alert
alert.dismiss();//to cancel alert

Is This Answer Correct ?    19 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference b/w close () and quit ()?

530


How to export selenium ide test suite to selenium rc suites?

487


Explain what is the main difference between web-driver and rc?

440


What is the purpose of the getoptions() method?

434


How will you handle working with multiple windows in selenium?

457






How to scroll down to a particular element?

3137


How will you find an element using selenium?

482


Explain me how can we capture screenshots in selenium?

452


Explain how you can find broken images in a page using selenium web driver?

446


What are the types of waits available in selenium webdriver?

452


Disadvantages of Hybrid Framework?

2409


How colors could be handled in selenium webdriver?

449


If one wanted to display the value of a variable named answer in the log file, what would the first argument to the previous command look like?

465


How to change the url on a webpage using selenium web driver?

451


When do we use findelement() and findelements()?

464