Watir noob here. I'm attempting to connect to and manipulate a newly spawned browser tab, but am a little confused about how to recognize the new tab. Here's what I have:
Windows 7 (32 bit) IE 10
Ruby 1.9.3-p392/TDM-32.4.5.2
LOCAL GEMS
watir (4.0.2 x86-mingw32)
watir-classic (3.6.0)
watir-webdriver (0.6.3)
Basic gist of the Script:
require 'rubygems'
require 'Watir'
ie=Watir::Browser.new
... First part of the script on the original browser tab is completed. The original browser tab generates a second browser tab, which I need to access. I've read a response somewhere that I need to link to the browser tab prior to attaching to it, but I'm having a hard time recognizing the link by the href, url or title: (where 'path...' = http url)
ie.link(:href, "path...").click
--Uncaught exception: Unable to locate element, using {:tag_name=>["a"], :href=>"path..."
ie.link(:url, "path...").click
--Uncaught exception: Unable to locate element, using {:tag_name=>["a"], :url=>"path..."
ie.a(:href, "path...").click
--Unable to locate element, using {:tag_name=>["a"], :url=>"path..."}
However, if I try the following:
ie2 = Watir::IE.attach(:title, 'New_Tab_Title')
--"Unable to locate a window with title of New_Tab_Title"
Firstly, how do I point to the new url or browser tab? If I do a ie.close after the second tab opens, the first tab closes, so clearly I don't recognize this new tab (even if it appears to have focus).
Secondly, am I correct in assuming that I need to connect to the link/url first, then attach to the browser tab, then I can continue with populating fields?
Lastly, is there a short name url I can use, as the url generated is very long, or do we need to insert the entire url?