Monday 3 August 2015

Alert generating and Accepting using Selenium WebDriver

package testNG;

import org.junit.Test;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class AlertGeneration {

    WebDriver driver = new FirefoxDriver();
   
    @Test
     public void test () throws InterruptedException { 
      //Generating Alert Using Javascript Executor
      JavascriptExecutor javascript = (JavascriptExecutor) driver;
      javascript.executeScript("alert('Test Case Execution Is started Now..');");
      Thread.sleep(2000);
      driver.switchTo().alert().accept();
   
     }
}

No comments:

Post a Comment