另一个女仆问题。此代码有效,直到add_task
...
登录后,身份验证窗口关闭并使用登录密钥返回主窗口。但我得到这个错误:
你好呀
测试 add_task
[远程服务器] file:///var/folders/3w/b7rcpqfj7kl3wtv56jt99yx00000gn/T/webdriver-profile20120919-9069-1ua1lm9/extensions/fxdriver@googlecode.com/components/command_processor.js:10212:in `unknown': 窗口不是成立。浏览器窗口可能已关闭。(Selenium::WebDriver::Error::NoSuchWindowError)
require 'rubygems'
require 'test/unit'
require 'watir-webdriver'
class Login
def basic_auth(logintype,usr,pwd)
$browser.goto("http://change.com")
$browser.link(:class,'joinchange').wait_until_present
join_link = $browser.link(:class,'joinchange')
join_link.click
$browser.window(:title, 'Sign In').wait_until_present
$browser.window(:title, 'Sign In').use
if logintype == 'fb'
$browser.link(:name, 'login-facebook id=').click
$browser.text_field(:id,'email').set(usr)
$browser.text_field(:id,'pass').set(pwd)
puts 'form submit'
sleep 3
$browser.form(:id,'login_form').submit
puts 'hello world'
else
$browser.text_field(:id,'lgnId').set('changes')
$browser.text_field(:id,'pwdId').set('letmeinnow')
sleep 3
$browser.form(:name,'LoginActionForm').submit
puts 'hi there'
end
end
def add_task
puts "testing add_task"
$browser.link(:class,'nextStep').click
end
end
$browser = Watir::Browser.new
login = Login.new
login.basic_auth('test','usr','pwd')
sleep 3
login.add_task