装配webdriver chrome浏览器支持

安装webdriver chrome浏览器支持

如何安装webdriver chrome浏览器支持

在gem 安装完watir-webdriver后,默认情况下chrome浏览器的支持是没有安装上的。 所以如果要使用webdriver测试chrome的话,我们需要手动安装chrome支持。

Requirements The ChromeDriver controls the browser using Chrome's automation proxy framework. Consequently, the ChromeDriver is only compatible with Chrome version 12.0.712.0 or newer.

从官方文档上可以看出,chrome driver只支持chrome12.0712 以上的版本。

万事俱备后,首先下载chrome driver , 也可直接从附件下载 ,

然后将下载好的chromedriver.exe放在环境变量所配置的文件夹中, 如放在chrome安装目录下“D:\program files\Chrome\Application”。

 

程序中设置:System.setProperty("webdriver.chrome.driver", "D:/program files/Chrome/Application/chromedriver.exe");

WebDriver driver = new ChromeDriver();

driver.get("http://baidu.com");

即可使用.

 

使用下面的代码测试chrome driver是否安装完成:

#使用watir-webdriver语法
#安装成功后则可以启动chrome并打开腾讯首页
@browser = Watir::Browser.new :chrome
@browser.goto 'www.qq.com'