0

操作系统 Windows 7 64、IE 9.0、Ruby200-x64

宝石:

bigdecimal (1.2.0)
bson (1.8.6)
childprocess (0.3.9)
commonwatir (4.0.0)
ffi (1.8.1)
io-console (0.4.2)
json (1.7.7)
mini_portile (0.5.0)
minitest (4.3.2)
multi_json (1.7.3)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
rubygems-update (2.0.3)
rubyzip (0.9.9)
selenium-webdriver (2.32.1)
test-unit (2.0.0.0)
watir (4.0.2)
watir-webdriver (0.6.4)
websocket (1.0.7)
win32-api (1.4.8)
win32-process (0.7.2)
windows-api (0.4.2)
windows-pr (1.2.2)

代码:

require 'rubygems'
require 'watir-webdriver'

app_url = "https://url"
@username = "ID"
@password = "password"

ch = Watir::Browser.new :ie

puts "Start test - GES Login/Add"
puts "Go to url: " + app_url
ch.goto app_url
sleep 2

我明白了

C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/lib/selenium/w
ebdriver/remote/response.rb:52:in `assert_ok': Modal dialog present (Selenium::W
ebDriver::Error::UnhandledAlertError)
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/response.rb:15:in `initialize'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/http/common.rb:59:in `new'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/http/common.rb:59:in `create_response'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/http/default.rb:66:in `request'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/http/common.rb:40:in `call'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/bridge.rb:619:in `raw_execute'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/bridge.rb:597:in `execute'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/bridge.rb:159:in `getCurrentUrl'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/common/driver.rb:120:in `current_url'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/watir-webdriver-0.6.4/lib/w
atir-webdriver/browser.rb:111:in `url'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/watir-webdriver-0.6.4/lib/w
atir-webdriver/browser.rb:80:in `goto'
        from example_login.rb:12:in `<main>'

我已经尝试了所有可以找到的基本身份验证示例,但似乎没有一个能够识别模式对话框。这是一个简单的 Windows 安全弹出窗口,要求输入用户名和密码,并带有 Windows 基本身份验证的确定或取消按钮。

有什么建议么?

4

2 回答 2

0

您可以尝试使用 RAutomation gem - https://github.com/jarmo/RAutomation

gem 可用于自动化窗口的窗口。如果您使用 watir-classic,它实际上使用 rautomation 来执行一些操作(例如保存文件(如果我没记错的话))。它由与 watir-classic 相同的开发人员开发,因此具有相同的直观 api。请注意,如果您使用 watir-webdriver(假设您在 Windows 上运行),您仍然可以使用 rautomation。

于 2013-06-07T02:56:24.300 回答
0

您可以在 Firefox 浏览器中尝试此操作(如果在 ie 中不强制进行测试),使用 Autoauth Add-on。

调用已安装 Autoauth 附加组件的 Firefox 配置文件,它将自动执行基本身份验证。您可以在https://addons.mozilla.org/en-us/firefox/addon/autoauth/中找到 Autoauth

于 2013-06-04T09:25:17.120 回答