无法处理基本身份验证窗口
我正在处理弹出窗口,即处理基本身份验证窗口。请找到下面的代码,我正在尝试运行测试,
{
require 'watir/ie'
require 'win32ole'
require 'watir/WindowHelper'
ie=Watir::IE.new
ie.goto "http://www.google.com"
helper = WindowHelper.new
helper.logon('Connect to proxy1','Mohammed','WE8SR') # where title=Connect to Proxy1 is the auth window,User name= Mohammed and Password=WE8SR.
puts x.inspect
ie.close
}
发生的情况是用户名和密码从未在身份验证窗口中输入,并且超时错误
显示。
ruby google_search.rb
C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:494:in sleep': execution expired (Timeout::Error)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:494:in block in wait'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:491:in wait'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:357:in goto'
from google_search.rb:96:in `<main>'
>Exit code: 1
这是我使用的Ruby 1.9.2版本的问题吗?
我修改了 WindowHelper.rb
中方法 logon
的代码并尝试执行此操作。
// Actual method in the "WindowHelper.rb" file
{
def logon(title,name = 'john doe',password = 'john doe')
@autoit.WinWait title, ""
@autoit.Send name
@autoit.Send "{TAB}"
@autoit.Send password
@autoit.Send "{ENTER}"
end
}
我修改过的代码有时可以工作,
{
def logon(title,name,password)
@autoit.WinWait title, ""
@autoit.Send name
@autoit.Send "{TAB}"
@autoit.Send password
@autoit.Send "{ENTER}"
end
}
我已经在各种博客中尝试过解决方案。如果我遗漏了什么,请建议我。
Iam working on Popup windows i.e. handling Basic Authentication windows.Please find the below code which I am trying to run the test with
{
require 'watir/ie'
require 'win32ole'
require 'watir/WindowHelper'
ie=Watir::IE.new
ie.goto "http://www.google.com"
helper = WindowHelper.new
helper.logon('Connect to proxy1','Mohammed','WE8SR') # where title=Connect to Proxy1 is the auth window,User name= Mohammed and Password=WE8SR.
puts x.inspect
ie.close
}
What happens is the User Name and Password is never typed in the Authentication Window and Timedout Error
is displayed.
ruby google_search.rb
C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:494:in sleep': execution expired (Timeout::Error)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:494:in block in wait'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:491:in wait'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:357:in goto'
from google_search.rb:96:in `<main>'
>Exit code: 1
Is this the problem with the version of Ruby 1.9.2 which I am using?
I modified the code for a method logon
in the WindowHelper.rb
and tried doing it.
// Actual method in the "WindowHelper.rb" file
{
def logon(title,name = 'john doe',password = 'john doe')
@autoit.WinWait title, ""
@autoit.Send name
@autoit.Send "{TAB}"
@autoit.Send password
@autoit.Send "{ENTER}"
end
}
Code which I modified to and found working sometimes
{
def logon(title,name,password)
@autoit.WinWait title, ""
@autoit.Send name
@autoit.Send "{TAB}"
@autoit.Send password
@autoit.Send "{ENTER}"
end
}
I have tried for the solution in various blogs. Suggest me if I am missing something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您的脚本在处理 BASIC 身份验证之前停止了,因为您的错误文本表示 goto 方法中使用的 wait 方法发生超时错误。
尝试 ie.navigate 方法而不是 goto 方法,如下所示
I guess your script stopped before handling BASIC Authentication because your error text said Timeout error occured at wait method which is used in goto method.
try ie.navigate method instead of goto method like the following