[英]Using default Firefox profile in Watir Webdriver but switching off JavaScript
I would like to use my default profile in firefox when watir-webdriver launches a friefox browser, but then I want to switch off javascript in that browser this way: 当watir-webdriver启动friefox浏览器时,我想在firefox中使用默认配置文件,但随后我想以这种方式关闭该浏览器中的javascript:
browser = Watir::Browser.new :ff, :profile => "default"
browser.profile['javascript.enabled']=false
The second reference doesn't work, because the "profile" is not a member of the browser object. 第二个引用不起作用,因为“配置文件”不是浏览器对象的成员。 How can I access it? 我该如何访问? Or any other method to switch off javascript either in the default profile or in the running firefox window? 还是在默认配置文件或正在运行的firefox窗口中关闭javascript的任何其他方法? I want to do this programmatically, because at the end of my Ruby script I would like to switch it on again. 我想以编程方式执行此操作,因为在我的Ruby脚本结尾处,我想再次将其打开。
I think you would do it like this: 我想您会这样做:
profile = Selenium::WebDriver::Firefox::Profile.new
profile['javascript.enabled'] = false
browser = Watir::Browser.new :ff, :profile => profile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.