【发布时间】:2016-09-16 23:28:23
【问题描述】:
我编写了下面的代码来在 chrome 浏览器中打开一个站点并验证它的标题。但是当使用System.setProperty() 设置ChromeDriver 路径时,它给了我语法错误,当我评论我得到的行时:
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property..
我的代码:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
public class FirsttestNGFile {
String BaseURL = "http://newtours.demoaut.com/";
System.setProperty("webdriver.chrome.driver", "E:\\Automation Jars\\chromedriver_win32\\chromedriver.exe"); -- If I comment this line, I get Illegal state Exception for chromedriver path; if not commented , I get syntax error
WebDriver driver = new ChromeDriver();
@Test
public void verifyHomePageTitle() {
driver.get(BaseURL);
String ExpectedTitle = "Welcome: Mercury Tours";
String ActualTitle = driver.getTitle();
Assert.assertEquals(ExpectedTitle, ActualTitle);
driver.quit();
}
}
【问题讨论】:
-
我也试过Project->Clean;但这也无济于事
标签: java eclipse selenium testng