Is there an alternative to watir :: ie.attach for watir-webdriver, since the application is not supported on webdriver

I have a website that only displays in a browser with Webkit support (Google Chrome, Safari). I am using Google Chrome since I am in Windows 7.

I use Watir-WebDriver to automate the same.

Problem. When I click a button in a browser window, another window launches, and the content of the clicks is displayed in a new browser window. I need a way to identify this new browser window in order to continue testing. I read in various forums, but did not get any specific answer / solution.

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

Code example:

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 
+4
source share
3 answers

The "window" method is an alternative for ie.attach. Webdriver can handle an open window using the window method.

 b.link(:href,/server\/getPage/).click b.window(:url,/server\/getPage/i).use do b.link(:id,"btn_MAP").click end 

You can handle pop-ups in the window method block. If you want to continue to process the popup, use it without a block, for example window (: url, / foobar /). Use

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

+7
source

@ Yutaka: Thank you very much for your help, it made me use something like the following and it worked!

b.link. (: XPath, "/ html / body / DIV / μl / Li / a") click

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

c.use

b.link (: identifier, "btn_MAP"). Click

+1
source

Have you tried making your website the default homepage for your browser?

which may prevent you from attaching.

0
source

All Articles