below On Thursday, April 19, 2012 1:48:13 PM UTC-7, Michael Goldberg wrote: > > Hi, > > I am new to Watir. > I have been using AutoIT for a lot of my automation, and find that in > some instances I am unable to do what I need due to the complicated > scripting of webpages. I looked into other languages and thought Watir > would be a nice fit for what I need. > > I have a few questions, I was hoping someone might be able to answer. > > 1) Syntax, > Looking at different examples on the web I see the sometimes > ie.frame(:index, 1) is used and other times ie.frame(:index => 1) is > used, what is the difference? Sometimes one works for me other times > they don't. > The content of the parenthesis is basically one or more pairs of label&value that tells watir how to identify the element. The way Ruby works , you can do any of the following (where 'how' is something like id, name, etc, and 'what' is a value)
browser.element(:how, 'what') browser.element(:how => 'what) browser.element(:how1 => 'what1', :how2 => 'what2') (or more pairs if needed) We used to show just the first instance in most of our docs, but this got confusing for people when then later showing how to use multiple criteria (the third example), so we switch to the => style since it is more consistent, and it's easier to explain just add a comma and another set of :how => 'what', if you need more than one criteria to create a unique way to identify and object. Most of the time you see the comma version, or 'ie' instead of 'browser' you are looking at an older piece of documentation > > 2)Output, > How do I see what I am doing? > With Autoit, I was able to see what i was doing via the console? > I would find the object, and print out the innerhtml to make sure I > was in the correct spot? Is there something similar in Watir? Is > there a command to see the text and / or html of an object? > Lots of ways to do this. Firstly learn a bit about IRB which allows you to enter a command at a time and see things happen. For seeing if I have the right object, I use the .flash method a lot, but you can also examine properties such as .text or .html If you look at the rdoc you can see what objects support what methods, but pretty much if it makes sense it's likely to work. (in other words don't expect an image element to have .text, but do expect it to have .height and .width) when in doubt, refer to the rdoc (http://rubydoc.info/github/watir/watir-webdriver/master/frames) > > 3)I am having issues connecting to frames. > I connect to IE fine, and then run ie.show_frames > It prints out a list of frames on the screen. > I try the syntax ie.frame(:index, 1) and i get an error message > stating located=false > If I try ie.frame(:index, 1).locate, it seems that I get connected. > But then when I try going deeper into another nested frame I keep > getting error messages. > > I visited the wiki page http://wiki.openqa.org/display/WTR/Frames > and when I try their example > > ie.frame(:name, "frame").frame(:name, "nested_frame") > > this doesn't work I'm assuming because > this doesn't work - ie.frame(:name, "frame") > > I would appreciate any help available > Likely there the problem is that you are looking at an older doc that needs to be updated to account for the change from one based to zero based indexing. To be more compatible with how ruby works, how webdriver works etc we've moved watir from index values that start with 1 being the first instance, to 0 being the first instance. Only use index values if there is not some other better way such as an ID, or Name to identify the frame. If you can show us the HTML for the frame, I (or someone else) could give you a more specific example > Thanks, Mike You didn't ask, but I recommend you move to using watir-webdriver. That gives your cross browser support (where watir only supports IE) and will run on operating systems other than windows. It's the future direction the watir project is moving in. -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected]
