如何在 Ubuntu Linux 上使用 FireWatir 进行基本身份验证?
我正在尝试使用 FireWatir (1.6.5) 来使用 Basic 访问网站 身份验证,我一直无法找到有效的解决方案 Linux 中的火狐浏览器。 FireWatir 1.6.5 是否支持基本身份验证 在 Linux 上?我在网上找了两天了,没找到 直接回答任何地方如何做到这一点。
我发现唯一有用的线程是这个( http: //groups.google.com/group/watir-general/browse_thread/thread/d8ab9a177d282ce4/fc1bf2319fb387d8?lnk=gst&q=basic+authentication#fc1bf2319fb387d8)。
Aedorn Varanis 说:“Angrez 的叉子有解决方案,所以我正在使用它 现在。谢谢安格雷兹,工作完美!”,但他没有提到他做什么 做了让事情正常运转的事情。
最初,我尝试使用以下方法绕过身份验证对话框:
browser.goto('http://admin:[电子邮件受保护]')
但是,这会生成一个“确认”对话框,其中显示:
“您即将登录该网站” 172.20.1.1" 和用户名 “admin”。“[取消,确定]
此对话框会阻塞,并且在单击“确定”之前,转到调用不会返回。
然后我尝试添加:
browser.startClicker(“ok”) browser.goto('http://admin: [电子邮件受保护]')
但这也会生成相同的“确认”对话框。
我使用单元测试 /var/ 测试了 startClicker 功能 lib/gems/1.8/gems/firewatir-1.6.5/unittests/html/JavascriptClick.html 它工作得很好,这让我认为使用 startClicker 方法不是处理确认对话框的正确方法。
其他人找到了一种让基本身份验证工作的方法,或者如何单击 确认对话框中的“确定”?我已经无计可施了...
I'm trying to use FireWatir (1.6.5) to access a site using Basic
Authentication and I've been unable to find a solution that works on
Firefox in Linux. Does FireWatir 1.6.5 support Basic Authentication
on Linux? I've been searching the web for 2 days and can't get a
straight answer anywhere as to how to do this.
The only thread I found that seemed helpful was this one (
http://groups.google.com/group/watir-general/browse_thread/thread/d8ab9a177d282ce4/fc1bf2319fb387d8?lnk=gst&q=basic+authentication#fc1bf2319fb387d8).
Aedorn Varanis says " Angrez's fork had the solution so I'm using that
now. Thanks Angrez, works perfectly!", but he doesn't mention what he
did to get things working.
Initially I tried to bypass the authentication dialog box by using:
browser.goto('http://admin:[email protected]')
However, this generates a "Confirm" dialog which says:
"You are about to log in to the site "172.20.1.1" with the username
"admin"." [Cancel, OK]
This dialog blocks, and the goto call won't return until I click "OK".
Then I tried adding:
browser.startClicker("ok")
browser.goto('http://admin:[email protected]')
But this ALSO generates the same "Confirm" dialog.
I tested out the startClicker functionality using the unit test /var/
lib/gems/1.8/gems/firewatir-1.6.5/unittests/html/JavascriptClick.html
and it worked fine, which makes me think that using the startClicker
method is NOT the correct way to take care of the Confirm dialog.
Anybody else found a way to get Basic Auth to work, or how to click
the OK on the confirm dialog? I'm at my wits end...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能是一个漫长而丑陋的解决方法,也可能违反了 watir 哲学的简单性,但既然你已经无计可施了......
1) Sahi (http://sahi.co.in/) 通过将 401 身份验证对话框转换为常规网页来处理它们。
2) Sahi 的代理需要运行,并且您将浏览器指向使用 Sahi 的代理。
3) 然后您可以导航到您的页面,只需使用 watir/firewatir 将用户名密码输入到转换后的 401 身份验证网页中(就像常规表单一样)。
您会承受代理的额外负载,但 Sahi 的表现相当良好,因此您应该能够使其正常工作。
如果您需要进一步的帮助,您可以在此处或 Sahi 的论坛上发帖。
希望有帮助。
-纳拉扬
This may be a long ugly workaround, and may also violate the simplicity of watir's philosophy, but since you are at your wits end ...
1) Sahi (http://sahi.co.in/) handles 401 authentication dialogs by converting them into regular web pages.
2) Sahi's proxy needs to be running, and you point your browser to use Sahi's proxy.
3) You can then navigate to your page and just use watir/firewatir to enter username password into a converted 401 authentication web page, (like a regular form).
You would incur the extra load of the proxy, but Sahi is fairly well behaved so you should be able to make it work.
You could post here or on Sahi's forums if you need further assistance.
Hope that helps.
-Narayan
在 Aedorn Varanis 的帮助下,我已经在 Firefox 上工作了
Linux。
Aedorn 向我发送了一个“登录”方法,该方法发出 jssh 命令
检查“需要身份验证”对话框,如果存在,则填充
在用户名/密码中并提交对话框。
我复制并粘贴了他发给我的内容如下:
由此,我能够使用以下方法对 FireWatir::Firefox 类进行子类化:
新的浏览器类支持“credentials=”方法,就像
Celerity::浏览器可以。因此,就像使用 celerity 一样,您可以执行以下操作:
这将自动填写基本身份验证对话框并让您登录
该网站。
我已在下面发布了 browser.rb 文件的内容(请注意
适用于 Linux 中的 ruby+firewatir 和 jruby+celerity):
With help from Aedorn Varanis I've got things working on Firefox in
Linux.
Aedorn sent me a "logon" method which issues a jssh command that
checks for an "Authentication Required" dialog and if it exists, fills
in the username/password and submits the dialog.
I've copied and pasted what he sent me below:
From this, I was able to subclass the FireWatir::Firefox class with a
new Browser class which supports a "credentials=" method just like the
Celerity::Browser does. So, just like using celerity, you can do:
This will automatically fill in the Basic Auth dialog and log you into
the site.
I've posted the contents of my browser.rb file below (notice this
works in ruby+firewatir and jruby+celerity in linux):
我一直在与这个问题作斗争,直到今天。显然我多次忽略了答案,因为它看起来不合理。然而,解决方案在于 Firefox 的“network.http.phishy-userpass-length”配置文件配置。如果 FireWatir 允许您修改您的 Firefox 实例配置文件,那么您可以将“network.http.phishy-userpass-length”的值指定为 255,这将使该对话框消失。检查 http://kb.mozillazine.org/Network.http.phishy-userpass-长度了解更多详细信息。
注意:使用 Ruby 中的 Capybara + selenium-webdriver,我做到了;
I battled long and hard with this issue until today. Apparently i overlooked the answer many times because it didn't look plausible. However, the solution lies in Firefox's "network.http.phishy-userpass-length" profile configuration. If FireWatir allows you to modify your firefox instance Profile, then you can give the "network.http.phishy-userpass-length" a value of 255 which should make that dialog disappear. check http://kb.mozillazine.org/Network.http.phishy-userpass-length for more details.
Note: With Capybara + selenium-webdriver in Ruby, I did;