当我使用下面的代码时,我收到错误:" java.lang.IllegalStateException:驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置;"
import io.github.bonigarcia.wdm.ChromeDriverManager;
import io.github.bonigarcia.wdm.EdgeDriverManager;
import io.github.bonigarcia.wdm.FirefoxDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
public enum InitialDrivers {
INSTANCE;
public static InitialDrivers getInstance()
{
return INSTANCE;
}
public static WebDriver driver = null;
public void selectDriver() {
Drivers driverName = Drivers.valueOf(readXML("baseData","driver"));
switch (driverName)
case Chrome: {
ChromeDriverManager.getInstance().setup();
ChromeOptions options = new ChromeOptions();
options.setCapability("browserName","chrome");
driver = new ChromeDriver(options);
break;
}
case Firefox: {
FirefoxDriverManager.getInstance().setup();
FirefoxOptions options = new FirefoxOptions();
options.setCapability("marionette", true);
driver = new FirefoxDriver(options);
break;
}
case Edge: {
EdgeDriverManager.getInstance().setup();
EdgeOptions options = new EdgeOptions();
options.setCapability("browserName", "MicrosoftEdge");
driver = new EdgeDriver(options);
break;
}
}
}
public enum Drivers {Chrome, Firefox, Edge}
}
我正在使用这种依赖:
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>2.1.0</version>
此代码在一台计算机上运行良好,但在另一台计算机上运行失败。帮我解决这个问题,谢谢