three things: 1) fix the typo.. ie.test_field will give you an undefined method error.. (heh I make that same typo myself a LOT.. my fngers like to type 'test' instead of 'text' go figure)
2) you are missing a colon in front of 'name' the format for these things is always <browserobject>.<page-element> (<attributetype>,<attributevalue>) usually followed by a method unless you are dealing with really simple elements like the page title. The attribute type values start with colons, and are things like :id, :name, :url, etc. One of the cheat-sheets in the docs is a table that lists what attributes can be used with what page elements. (apologies to the watir devs if I've misnamed things in my simple syntax example here) 3) doing just what you had (typos corrected) wll return the entire text_field object and try to cast it to a string (even if that works, I've no idea what it will do). To get just the value of the field you need to add the method .value at the end e.g. result1= ie.text_field(:name,"Day").value I find the easiest way to make sure that something like the above is going to work is to use IRB. create an irb session, make your browser object (I call mine 'browser' not 'ie', since I intend to run these scripts against multiple browsers, not just ie), navigate to the page turn on the developer toolbar or firebug to be able to see how objects are defined in the DOM, (I find this much easier than viewing source) and then use things like browser.text_field(:name,"Day").flash as a simple test to see if you've managed to properly identify the page element. You can then do something like puts ie.text_field(:name,"Day").value to verify that the value returned is what you'd expect. it it works copy from the IRB window and past into your code.. wash rinse repeat as needed a lot of times I don't need to test every line of code this way, but if I get to a particular object, and really want to be sure the code is going to return the value I'd expect, click the link I'd expect, etc then I find it a LOT easier to just run that line of code in IRB and see what happens, than having to run my entire script. On Mar 9, 9:30 am, maximore <[email protected]> wrote: > Case : I want in ruby to read a valued in a application form > that was entered: > > Let say the input into the field name call : Day was enter to > be 5 > then I want to read the field value also to check that the correct > input value is entered . > result1; > > The value is then passed to a variable name result1..... > > result1= ie.test_field(name,"Day").name.to_s > > Please take a look . Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to [email protected] Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---
