Paweł Zarębski
Paweł Zarębski

Reputation: 21

Entering data into input <Selenium | Watir Ruby>

I would like to enter text in the search engine field of the website. I can select input correctly. However, an error occurs when trying to use:

*undefined method `set 'for # Watir :: Input: 0x000055c93c73b850> *

Code:

      sleep 1
      advencedSearch = @ browser.div (: class => "search")
      advencedSearch.a.click ()
      sleep 1
      productSearch = @ browser.div (: class => "filter")
      productSearch.input.click ()
      productSearch.input (: placeholder => "Name or code").set('hi')```

Upvotes: 2

Views: 74

Answers (1)

Justin Ko
Justin Ko

Reputation: 46836

The Watir::Input is a generic class for all input elements. Typically (always?) you want to work with the type specific classes - eg Watir::TextField. These specific classes are where methods like #set will be available.

Try using #text_field instead of #input:

productSearch.text_field(: placeholder => "Name or code").set('hi')

Upvotes: 2

Related Questions