mih*_*ijs 3 watir watir-webdriver
如何使用watir脚本中禁用的Flash插件运行Chrome/Firefox?
如果我在Chrome中禁用了Flash,则下次执行watir-webdriver脚本时会再次启用Flash.
对于Firefox来说很简单.在默认配置文件(通常使用的配置文件)中禁用闪存,然后像这样启动浏览器:
browser = Watir::Browser.new :firefox, :profile => "default"
Run Code Online (Sandbox Code Playgroud)
更多信息:http://watirwebdriver.com/firefox/
对于Chrome我认为这样做会,但看起来我做错了,因为启用了闪存:
browser = Watir::Browser.new :chrome, :switches => ["--disable-internal-flash"]
Run Code Online (Sandbox Code Playgroud)
更多信息:http://watirwebdriver.com/chrome/
解决方法是每次要在Chrome中禁用Flash时运行此操作:
browser.goto "about:plugins"
browser.span(:text => "Flash").parent.parent.parent.a(:text => "Disable", :class => "disable-group-link").click
Run Code Online (Sandbox Code Playgroud)