Java中的Chromedriver无法执行 [英] Chromedriver in Java not executable

查看:491
本文介绍了Java中的Chromedriver无法执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在尝试学习Selenium,遇到了问题. 无法运行chromedriver.

So i'm trying to to learn Selenium and encountered a problem. Can't run chromedriver.

错误:

Exception in thread "main" java.lang.IllegalStateException: The driver is not executable: /Users/Roberto/Documents/EclipseProjects/MansPirmaisSelenium/lib/chromedriver

代码:

System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"//lib//chromedriver");
WebDriver chromeDriver = new ChromeDriver();
chromeDriver.get("http://www.google.lv");

我猜我的chromedriver在正确的路径上,这是图像.

I have my chromedriver in the right path i guess, here is the image.

推荐答案

我假设您刚刚下载了chromedriver应用程序,在这种情况下,您只需

I assume you just downloaded the chromedriver application, in which case you simply have to mark it as executable in Unix:

chmod +x chromedriver 

如果您可以从终端上自己运行应用程序,那么WebDriver也应该能够运行.

If you can run the application yourself from the terminal, then WebDriver should be able to as well.

顺便说一句,我不会在您的项目中包含chromedriver:

By the way, I wouldn't include chromedriver inside your project:

在您的PATH环境变量中包含ChromeDriver位置

include the ChromeDriver location in your PATH environment variable

这篇关于Java中的Chromedriver无法执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆