【发布时间】:2016-07-18 22:09:27
【问题描述】:
我是 Cucumber 的新手,使用 ChromeDriver 请求 URL 时出现以下错误:
java.lang.IllegalStateException:驱动程序可执行文件的路径 必须由 webdriver.chrome.driver 系统属性设置;更多 信息,请参阅http://code.google.com/p/selenium/wiki/ChromeDriver。 最新版本可以从 http://chromedriver.storage.googleapis.com/index.html 在 com.google.common.base.Preconditions.checkState(Preconditions.java:177)
我的代码:
package cucumber.features;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class AddToList {
WebDriver driver = null;
@Given("^I am on Todo site$")
public void onSite() throws Throwable {
driver = new ChromeDriver();
driver.navigate().to("http://localhost");
System.out.println("on todo site");
}
@When("^Enter a task in todo textbox$")
public void enterTask() throws Throwable {
driver = new ChromeDriver();
driver.findElement(By.name("task")).sendKeys("Test Unit Using Cucumber");
;
System.out.println("task entered");
}
@Then("^I click on add to todo$")
public void clickAddToTodo() throws Throwable {
driver = new ChromeDriver();
driver.findElement(By.xpath("//input[@value='Add to Todo' and @type='button']"));
System.out.println("add button clicked");
}
}
【问题讨论】:
标签: java selenium selenium-webdriver cucumber selenium-chromedriver