【发布时间】:2017-07-28 16:17:00
【问题描述】:
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();
}
}
这是我的第一个 selenium 程序。我在 eclipse 中输入这段代码,并为 selenium 添加外部 jar 文件,当我运行 eclipse 时说:
所选内容无法启动,并且最近没有启动。
如何解决?
【问题讨论】: