ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

How can we handle web based pop up?

How can we handle web based pop up?

WebDriver offers the users with a very efficient way to handle these pop ups using Alert interface. There are the four methods that we would be using along with the Alert interface.

void dismiss() – The accept() method clicks on the “Cancel” button as soon as the pop up window appears.

void accept() – The accept() method clicks on the “Ok” button as soon as the pop up window appears.

String getText() – The getText() method returns the text displayed on the alert box.

•void sendKeys(String stringToSend) – The sendKeys() method enters the specified string pattern into the alert box.

  1. //Syntax:
  2. // accepting javascript alert
  3. Alert alert = driver.switchTo().alert();
  4. alert.accept();
Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!