On Oct 14, 8:48 am, Matt <[email protected]> wrote:
> Hello everyone,
>
> I'm currently having some trouble with the return Win32OLE from the
> elements_by_xpath function.
>
> Scenario: Website with 4 TOTALLY identical text boxes.
> Task: Enter hello into 3rd and 4th.
>
> puts browser.text_field(:name, "TF_1").class
> -> outputs Watir::TextField
>
> my_lis = []
> my_lis = browser.elements_by_xpath("//p[@class='qbody']/
> input[@name='TF_1']")
> puts my_lis[0].value
>
> -> outputs "my default"
>
> @@@   ALTHOUGH @@@
> puts browser.text_field(:name, "TF_1").class
> -> outputs WIN32OLE
>
> As such when I try to set the value like so
>  my_lis[0].set("new text string")
> -> Output `method_missing': unknown property or method:
> `set' (NoMethodError)
>     HRESULT error code:0x80020006
>       Unknown name.
>
> Any help would be greatly appreciated,
>
> - Matt

Um, presuming '3rd and 4th' appears on the screen in the same order as
it's found in the tom, then why not

browser.text_field(:name => "TF_1", :index => 2).set  "hello"
browser.text_field(:name => "TF_1", :index => 3).set  "hello"

You can put that into a loop if you want and use a variable for the
index (which starts at zero unless you enable one based indexing)
and best of all, no need to mess around with xpath

-- 
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]

Reply via email to