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 between @factory and @data provider annotation?

533


Explain how you can switch back from a frame?

491


Just how much does selenium license cost per customer device?

495


Other than the default port 4444 how you can run selenium server?

475


What is the difference between driver.get() and driver.navigate.to()

515






What are the advantages and disadvantages of using selenium as testing tool?

485


Can we use selenium rc for tests driving on two different browsers on one operating system without selenium grid?

505


How to clear the text in the text box using selenium webdriver?

465


What is testng?

535


How you can login into any site if it’s showing any authentication popup for password and username?

542


When we use findElement () and findElements () findElement ()?

533


What test can selenium do?

528


What is the difference between “type” and “typeandwait” command?

1012


What is the main difference between the close() and quit() methods?

422


What are the steps to run automation using selenium?

525