java Chomedriver“驱动程序不可执行”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25720724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Chomedriver "The driver is not executable"
提问by Ghostleg
I have my chromedriver and chromedriver.exe right in project folder. I'm creating instance of driver with this code.
我的 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();
And it's ok on local windows (if we change "chromedriver" to "chromedriver.exe") , but when i'm running it on CentOS i got error message: "The driver is not executable".
在本地窗口上也可以(如果我们将“chromedriver”更改为“chromedriver.exe”),但是当我在 CentOS 上运行它时,我收到错误消息:“驱动程序不可执行”。
回答by German Petrov
Make it executable:
In CentOs use chmod +x chromedriver
使其可执行:在 CentOs 中使用 chmod +x chromedriver
回答by Nikhil Shah
- If User is using Unix that time first checks folder or chromedriver permission.
- Permission is missing then use below command.
chmod 777 *
- Above command change folder permission and Issue will resolve.
- 如果用户当时使用的是 Unix,则首先检查文件夹或 chromedriver 权限。
- 缺少权限,然后使用以下命令。
chmod 777 *
- 以上命令更改文件夹权限,问题将得到解决。
回答by sopan shirdhonkar
I had same problems but in my case the everything was working fine but suddenly I started getting this error, so It wouldn't be access problem I thought.
我遇到了同样的问题,但就我而言,一切正常,但突然间我开始收到此错误,因此我认为这不是访问问题。
So for reference to set the chrome driver or firefox driver I was using below snippet.
因此,作为参考,我在下面的代码段中使用了设置 chrome 驱动程序或 firefox 驱动程序。
Utils.setSystemProperty("webdriver.chrome.driver",
classLoader.getSystemResource("utilityJars" + File.separator + "chromedriver_mac").getPath());
I think case the path is in target folder when classes are compiled. So the value of
我认为在编译类时路径在目标文件夹中。所以的价值
classLoader.getSystemResource("utilityJars" + File.separator + "chromedriver_mac").getPath()
is
是
/{user.dir}/target/classes/utilityJars/chromedriver_mac
/{user.dir}/target/classes/utilityJars/chromedriver_mac
So may be it had some issue accessing chromedriver on that path, may be not compiled or something not sure, but I just deleted the target folder and re-executed it and it worked.
因此,可能在访问该路径上的 chromedriver 时遇到了一些问题,可能未编译或不确定,但我只是删除了目标文件夹并重新执行它并且它起作用了。
回答by Michelle
I ran into this problem as well. The first two answers given worked for me but you can also resolve the permission issue by going to the file (gecko file) that you have in your folder, right click>>Properties and then change the permissions from there.
我也遇到了这个问题。给出的前两个答案对我有用,但您也可以通过转到文件夹中的文件(gecko 文件),右键单击>>属性,然后从那里更改权限来解决权限问题。