package com.confirm;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class ConfirmDemo {
WebDriver driver = new FirefoxDriver();
@Test
public void ExampleForConfrim() throws InterruptedException {
driver.manage().window().maximize();
driver.get("file:///C:/confirm.html");
Thread.sleep(2000);
driver.findElement(By.xpath("//button[@onClick='confirmFunction()']"));
Alert alert=driver.switchTo().alert();
System.out.println(alert.getText());
alert.dismiss();
driver.close();
}
}
This is my first selenium program. I type this code in eclipse and also add external jar files for selenium, when I run the eclipse says :
The selection cannot be launch, and there are no recent launches.
How to solve this?