首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Is there an alternative to watir:ie.attach for watir-webdriver since attach is

2012-06-28 
Is there an alternative to watir::ie.attach for watir-webdriver since attach is原文链接?http://stac

Is there an alternative to watir::ie.attach for watir-webdriver since attach is

原文链接?http://stackoverflow.com/questions/5796059/is-there-an-alternative-to-watirie-attach-for-watir-webdriver-since-attach-is

Question:

I have a website which is only rendered in Webkit enabled browser (Google Chrome, Safari). I am using Google Chrome since I am on Windows 7.

I am using Watir-WebDriver to automate the same.

Issue: When I click on a button on the browser window, is launches another window and post click content is rendered in the new browser window. I need a way to be able to Identify this new browser window, in-order to be able to proceed with my testing. I have been reading on various forums, but not getting any certain answer/solution.

Q: Is there an alternative to watir::ie.attach for watir-webdriver since attach is not supported on Watir-Webdriver

Sample code:

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 openedb.goto(website)#this opens a new browser windowb.link(:xpath,"/html/body/div/ul/li/a").click#there is a button called "MAP" on the new browser windowb.link(:id,"btn_MAP")#this gives an error, unknown link
Answers:
A1:"window" method is the alternative for ie.attach. Webdriver can handle the window opened by itself with window method.
b.link(:href,/server\/getPage/).clickb.window(:url,/server\/getPage/i).use do  b.link(:id,"btn_MAP").clickend

you can handle popped up windows in the window method block. If you want to keep handling popped up window, use it without block, like window(:url,/foobar/).use

see also:?http://groups.google.com/group/watir-general/browse_thread/thread/232df221602d4cfb

?

A2:?Thanks a lot for all your help it lead me to use something like the following and it worked!

b.link(:xpath,"/html/body/div/ul/li/a").click

c = b.window(:url,"http:\/\/server\/getPage\/67\/1354")

c.use

b.link(:id,"btn_MAP").click

?

?

热点排行