当我尝试在Chrome上运行Selenium测试时,出现以下异常。尽管我设置了该属性,但仍然没有将webdriver.chrome.driver设置为异常
org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Command duration or timeout: 97 milliseconds
我查了一下,都用可执行文件的正确位置设置了webdriver.chrome.driver属性。我也将可执行文件放在我的路径中,但仍然收到相同的错误。代码片段如下。
//Importing jUnit and Selenium
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class SampleSeleniumTest {
@Test
public void sampleTest(){
System.setProperty("webdriver.chrome.driver","C:\\ChromeDriver\\chromedriver.exe");
System.out.print(System.getProperty("webdriver.chrome.driver"));
WebDriver driver = new RemoteWebDriver(DesiredCapabilities.chrome());
driver.quit();
}
}
你使用哪个硒版本? – sen4ik