如何使用 watir 脚本禁用 Flash 插件运行 Chrome/Firefox?

如何使用 watir 脚本禁用 Flash 插件运行 Chrome/Firefox?

问题描述:

如何使用 watir 脚本禁用 Flash 插件运行 Chrome/Firefox?

How to run Chrome/Firefox with disabled flash plugin from watir script?

如果我在 Chrome 中禁用 Flash,下次执行 watir-webdriver 脚本时 Flash 会再次启用.

If I disable flash in Chrome, next time when I execute watir-webdriver script Flash is enabled again.

对于 Firefox,这很容易.在您的默认配置文件(您通常使用的配置文件)中禁用 Flash,然后像这样启动浏览器:

For Firefox it is easy. Disable flash in your default profile (the one you normally use) and then start the browser like this:

browser = Watir::Browser.new :firefox, :profile => "default"

更多信息:http://watirwebdriver.com/firefox/

对于 Chrome,我认为这会做到,但看起来我做错了什么,因为启用了 Flash:

For Chrome I thought this would do it, but looks like I am doing something wrong, since flash is enabled:

browser = Watir::Browser.new :chrome, :switches => ["--disable-internal-flash"]

更多信息:http://watirwebdriver.com/chrome/

解决方法是每次您希望在 Chrome 中禁用 Flash 时都运行此程序:

Workaround is to run this every time you want Flash disabled in Chrome:

browser.goto "about:plugins"
browser.span(:text => "Flash").parent.parent.parent.a(:text => "Disable", :class => "disable-group-link").click