如何使用 watir 脚本禁用 Flash 插件运行 Chrome/Firefox? [英] How to run Chrome/Firefox with disabled flash plugin from watir script?

查看:30
本文介绍了如何使用 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

这篇关于如何使用 watir 脚本禁用 Flash 插件运行 Chrome/Firefox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆