简体   繁体   English

watir-webdriver和代理凭据

[英]watir-webdriver & proxy credentials

I'm trying to use watir-webdriver/ruby within a corporate environment but am encountering issues with the need for entering proxy credentials in order to access the system under test. 我正在尝试在公司环境中使用watir-webdriver / ruby​​,但是遇到访问代理凭据以访问受测系统的问题。

I've read various snippets from other forums, including Alister Scott's helpful tips on setting proxies in general and saving them to profiles. 我已经阅读了其他论坛上的各种摘要,包括Alister Scott关于设置代理并将其保存到个人资料的有用提示。 That, however still doesn't get me past the actual need to enter proxy credentials. 但是,这仍然不能使我超越输入代理凭据的实际需要。

Two tacks I can think of include 我可以想到的两个方法

Option 1: Somehow save the credentials in the same manner as the proxy itself. 选项1:以某种方式以与代理本身相同的方式保存凭据。 Eg 例如

profile = Selenium::WebDriver::Firefox::Profile.new
profile.proxy = Selenium::WebDriver::Proxy.new :http => 'myproxy.com:8080', :ssl =>     'myproxy.com:8080'
# COMMAND FOR PROXY CREDENTIALS?
b = Watir::Browser.new :firefox, :profile => profile

Option 2: Use my default profile which has the proxy credentials saved but still requires some webdriver code to click on the 'OK' button (and possibly more with the 'I Understand the Risks' dialog, etc. after) 选项2:使用保存了代理凭据的默认配置文件,但仍需要一些Webdriver代码才能单击“确定”按钮(之后可能还会显示“我了解风险”对话框,等等)

b = Watir::Browser.new :firefox, :profile => 'default'

I'm not allowed to post images yet as a newbie but dialog text says 我还不能以新手身份发布图像,但对话框文本会显示

The proxy [BLAH] is requesting a username and password. 代理[BLAH]正在请求用户名和密码。 The site says [BLAH] User Name: Password: [OK] [Cancel] 该网站说[BLAH]用户名:密码:[确定] [取消]

Any suggestions gladly welcomed. 任何建议都欢迎。

UPDATE I managed to get something to work which was using the default profile and tweaking a firefox setting called 'signon.autologin.proxy' - set this to true (tap in about:config in the browser, filter on 'prox' and it should appear to the bottom) 在浏览器上的“PROX”配置,过滤器,它应该: -更新我设法得到的东西的工作,其使用默认的配置文件和调整称为“signon.autologin.proxy” Firefox的设置这大约设置为true(自来水出现在底部)

Would still prefer a watir-webdriver based solution though ;-) 仍然会喜欢基于watir-webdriver的解决方案;-)

If you need one particular proxy server for a system under test and another for general usage, I would suggest that you look at using a PAC file for that. 如果您需要一个特定的代理服务器用于受测系统,而另一个则用于一般用途,那么建议您考虑使用PAC文件。 Link to Automatically Configuring Browsers for Proxy . 链接到自动配置代理浏览器

Example Script: 示例脚本:

function FindProxyForURL(url, host)
{
if (shExpMatch(url, "http://principia.mo.techpaths.com*")) {
return "DIRECT";
}
if (isInNet(myIpAddress(), "192.168.1.0", "255.255.255.0"))
return "PROXY 192.168.1.1:8080";
else
return "DIRECT";
}

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM