您的位置:首页 > Web前端 > JavaScript

Watir: Watir webdriver对JS 弹出框的操作现在非常简单。

2013-08-16 16:49 218 查看
以下代码支持Firefox,IE,Chrome
require 'watir-webdriver'
#require "watir-webdriver/extensions/alerts"
b = Watir::Browser.new :chrome
b.goto("http://192.168.10.110:ab/PersonInfo.aspx")
b.text_field(:id, "txtName").set("w3")
b.text_field(:id, "txtPwd").set("w3")
b.button(:id, "Logininfo").click
b.form(:id, "Form1").button(:name, "ctl00$MainContent$ctl00").click
b.link(:id, "MainContent_gridview_LinkButton1_0").click

if b.alert.present?
puts b.alert.text
b.alert.ok
end

browser.alert.ok # Will click OK button on the popup
browser.alert.close #Will click Cancel button/close on the popup
browser.alert.text #Will return the text on the popup
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: