OS 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基本身份验证的确定或取消按钮。
有什么建议吗?
答案 0 :(得分:0)
您可以在Firefox浏览器中尝试此操作(如果不是必须在ie中测试),请使用Autoauth Add-on。
调用已安装Autoauth Add-on的Firefox配置文件,该配置文件将自动执行基本身份验证。 您可以在https://addons.mozilla.org/en-us/firefox/addon/autoauth/
中找到Autoauth答案 1 :(得分:0)
您可以尝试使用RAutomation gem - https://github.com/jarmo/RAutomation
gem可用于自动化窗口的窗口。如果你使用watir-classic,它实际上使用rautomation来执行一些动作(例如保存文件(如果我没记错))。它由与watir-classic相同的开发人员开发,因此具有相同的直观api。请注意,如果您使用的是watir-webdriver(假设您在Windows上运行),仍然可以使用rautomation。