我有一个仅在启用 Webkit 的浏览器(Google Chrome、Safari)中呈现的网站。因为我在 Windows 7 上,所以我正在使用 Google Chrome。
我正在使用 Watir-WebDriver 来自动化它。
问题:当我单击浏览器窗口上的按钮时,会启动另一个窗口,并且单击后的内容会在新的浏览器窗口中呈现。我需要一种方法来识别这个新的浏览器窗口,以便能够继续我的测试。我一直在阅读各种论坛,但没有得到任何确定的答案/解决方案。
问:watir-webdriver 是否有替代 watir::ie.attach 的方法,因为 Watir-Webdriver 不支持 attach
示例代码:
require "rubygems"
require "watir-webdriver"
require "selenium-webdriver"
b = Watir::Browser.new(:chrome)
website = "http://xyz.com"
#a new browser is launched and the website is opened
b.goto(website)
#this opens a new browser window
b.link(:xpath,"/html/body/div/ul/li/a").click
#there is a button called "MAP" on the new browser window
b.link(:id,"btn_MAP")
#this gives an error, unknown link