2013-07-10 42 views
1

无论出于何种原因,watir都会更改我的Firefox浏览器设置,而无需执行此操作。Ruby Gem Watir不会被要求更改Firefox代理设置

如果我手动打开Firefox(在办公室),它通常设置为'无代理',并且工作得很好。

但是,如果watir启动一个新的FF实例,它将被设置为'手动代理',并且浏览器错误指出它试图使用拒绝连接的代理服务器。

我们在工作中没有代理服务器。

如何使用无代理服务器启动Firefox窗口?我搜索了网页,并没有找到一个这样的例子。 (顺便说一下,watir发起的会话中的FF设置与正常的FF设置无关;换句话说,手动更改FF设置并不能解决问题)。

+2

这个问题是关于Firefox在Ruby中使用'Watir'宝石时没有按预期开始的。因此,我认为这不应该被视为“脱离主题”。 –

+0

我同意。浏览器配置文件设置是“Watir”测试中的日常主题。 –

回答

4

基于信息here,有针对Firefox 5种不同的代理服务器配置:

0 
Direct connection, no proxy. (Default in Windows and Mac previous to 1.9.2.4 /Firefox 3.6.4) 
[edit] 
1 
Manual proxy configuration. 
[edit] 
2 
Proxy auto-configuration (PAC). 
[edit] 
4 
Auto-detect proxy settings. 
[edit] 
5 
Use system proxy settings. (Default in Linux; default for all platforms, starting in 1.9.2.4 /Firefox 3.6.4) 

它看起来像“0”是一个你需要的。我们设置为在Watir-Webdriver help page for Firefox描述:

profile = Selenium::WebDriver::Firefox::Profile.new 
profile["network.proxy.type"] = 0 
browser = Watir::Browser.new :firefox, :profile => profile 

所有的个人资料[“Lorem存有”]的类型选项都在约上市:在Firefox配置菜单的URL,并访问/以类似的方式改变。

+1

该代码片段工作得很好,它解决了我的问题。非常感谢!这也会帮助我的队友。 – user2569032

+0

我仍然想知道什么代理模式“3”,因为官方文档跳过这个号码... –