问题
How to run Chrome/Firefox with disabled flash plugin from watir script?
If I disable flash in Chrome, next time when I execute watir-webdriver script Flash is enabled again.
回答1:
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"
More information: http://watirwebdriver.com/firefox/
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"]
More information: http://watirwebdriver.com/chrome/
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
回答2:
Use the --disable-bundled-ppapi-flash
switch. The one above did not work for me.
来源:https://stackoverflow.com/questions/9636255/how-to-run-chrome-firefox-with-disabled-flash-plugin-from-watir-script