Undefined Method `set' for #<Watir::Input:0x102204a38> (NoMethodError)

734 views
Skip to first unread message

Usman Hussain

unread,
Nov 9, 2010, 11:04:57 AM11/9/10
to Watir General
Hi Guys,

I am trying to set a text field with the method set and it doesnt seem
to be working anymore.

The error im getting is: `set' for #<Watir::Input:0x102204a38>
(NoMethodError)

I am using Watir-WebDriver (version 0.1.1) and firefox as the browser.

My line of code is:
@browser.element_by_xpath("//div[@id= 'container']//div//input[@value=
'starofjoy.display']/../input[2]").set("true")

If I use send_keys instead of set then i end up with the text field
looking something like this:
falsetrue

BUT all i want is to change it from False to True...

has anyone else come across this problem?

Kind regards,
Usman Hussain

Jari Bakken

unread,
Nov 9, 2010, 11:19:24 AM11/9/10
to watir-...@googlegroups.com
Don't use element_by_xpath. If you want a text field, pass the xpath
to Browser#text_field:

browser.text_field(:xpath, "/your/xpath").set("foo")

Again, reading the docs would show you on what elements the #set
method is defined (e.g. not on Watir::Input).

> --
> Before posting, please read http://watir.com/support. In short: search before you ask, be nice.
>
> watir-...@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-genera...@googlegroups.com
>

Usman Hussain

unread,
Nov 9, 2010, 11:33:55 AM11/9/10
to Watir General
ahhhh yes. i just relaised that in a previous test i had done it the
way you said and I have no idea why I have done it this way this time.
small minor mistake on my behalf. thanks again for the speedy reply
Jari.
Thanks,
Usman

P.s. Only posted to one group this time...

On Nov 9, 4:19 pm, Jari Bakken <jari.bak...@gmail.com> wrote:
> Don't use element_by_xpath. If you want a text field, pass the xpath
> to Browser#text_field:
>
> browser.text_field(:xpath, "/your/xpath").set("foo")
>
> Again, reading the docs would show you on what elements the #set
> method is defined (e.g. not on Watir::Input).
>
>
>
> On Tue, Nov 9, 2010 at 5:04 PM, Usman Hussain <usmanhhuss...@gmail.com> wrote:
> > Hi Guys,
>
> > I am trying to set a text field with the method set and it doesnt seem
> > to be working anymore.
>
> > The error im getting is: `set' for #<Watir::Input:0x102204a38>
> > (NoMethodError)
>
> > I am using Watir-WebDriver (version 0.1.1) and firefox as the browser.
>
> > My line of code is:
> > @browser.element_by_xpath("//div[@id= 'container']//div//input[@value=
> > 'starofjoy.display']/../input[2]").set("true")
>
> > If I use send_keys instead of set then i end up with the text field
> > looking something like this:
> > falsetrue
>
> > BUT all i want is to change it from False to True...
>
> > has anyone else come across this problem?
>
> > Kind regards,
> > Usman Hussain
>
> > --
> > Before posting, please readhttp://watir.com/support. In short: search before you ask, be nice.
>
> > watir-...@googlegroups.com
> >http://groups.google.com/group/watir-general
> > watir-genera...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages