Mac OS X Yosemite 10.10.4下,ChromeDriver运行异常,需要手动安装chromedriver.exe

Step 1: 打开https://sites.google.com/a/chromium.org/chromedriver/downloads,找到最新版本的chromedriver.exe;

    (or from http://chromedriver.storage.googleapis.com/index.html)

Step 2: Mac下只有chromedriver_mac32.zip,无论是32的Mac还是64的Mac都下这个版本就行;<现在有mac64的了>

Step 3: 解压包,并添加后缀.exe;

Step 4: 打开Finder,在Go menu选择Go To Folder,输入/usr/bin或/usr/local/bin以打开该路径;

Step 5: 将chromedriver.exe放在/usr/bin或/usr/local/bin下面即可.

 

 

如果使用Chromedriver还报如下异常:

java.lang.IllegalStateException: 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

 

那需要在Java程序中添加:

System.setProperty("webdriver.chrome.driver","/usr/bin/chromedriver.exe");
WebDriver driver = new ChromeDriver();

 

如果遇到以下异常,可以先更新最新版的chromedriver.exe看看:

SessionNotCreatedError