ruby webdriver 启动chrome浏览器的一些小技巧

一般情况下我们启动chrome浏览器是用:

Selenium::WebDriver.for :chrome

但是有时候当我们访问一些特殊页面时,比如页面会提示证书错误,popup弹窗,是否翻译这些问题,有些会影响对页面的操作

只要在chrome的后面加上一个参数switches,问题就搞定了

Selenium::WebDriver.for:chrome,:switches =>%w[--ignore-certificate-errors --disable-popup-blocking --disable-translate]

参数的个数根据需要自己选填

eg:

dr = Selenium::WebDriver.for :chrome

dr.get "http://jp.msn.com"

这个时候会弹出是否翻译的信息

使用Selenium::WebDriver.for:chrome,:switches =>%w[--ignore-certificate-errors --disable-popup-blocking --disable-translate] 就可以让页面显得很干净,简洁~

 

原文地址:https://www.cnblogs.com/timsheng/p/2721557.html