-3
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();
}
}
這是我的第一個硒程序。我在eclipse中輸入這段代碼,並在seclipse中添加外部jar文件,當我運行eclipse時說:硒不能在月蝕上運行
選擇無法啓動,也沒有最近啓動。
如何解決這個問題?