我的 chromedriver 和 chromedriver.exe 就在项目文件夹中。 我正在使用此代码创建驱动程序实例。
ChromeOptions options = new ChromeOptions();
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
LoggingPreferences log_prefs = new LoggingPreferences();
log_prefs.enable(LogType.BROWSER, Level.SEVERE);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, log_prefs);
System.setProperty("webdriver.chrome.driver", "chromedriver");
driver = new ChromeDriver(capabilities);
driver.manage().window().maximize();
它在本地 Windows 上没问题(如果我们将“chromedriver”更改为“chromedriver.exe”),但是当我在 CentOS 上运行它时,我收到错误消息:“驱动程序不可执行”。
最佳答案
使其可执行:
在 CentOs 中使用 chmod +x chromedriver
关于java - Chrome 驱动程序 "The driver is not executable",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25720724/