cheezy / page-object

Gem to implement PageObject pattern in watir-webdriver and selenium-webdriver
MIT License
653 stars 220 forks source link

Problem with custom html attributes having dash characters #412

Closed djangofan closed 7 years ago

djangofan commented 7 years ago

I am encountering a problem with custom html attributes having dash characters.

I have HTML that looks like this: <input id='input-what' data-test='input-what'>

And here is the ERROR I get when I try to use a page-object accessor to access that data-test attribute:

3>     When I query 'A repair'                 # features/step_definitions/hs_steps.rb:8
3>       timed out after 30 seconds, waiting for {:data_test=>"input-what", :tag_name=>"textarea"} to be located (Watir::Exception::UnknownObjectException)
3>       (eval):1:in `process_watir_call'

It works fine if I just change my element to hook to the id instead of the custom attribute: text_field(:what, id: 'input-what')

Now, I can work around this for the moment, by bypassing page-object (see commented out code below), and using DIRECT Watir calls, with this code @titusfortner . This proves that Watir supports these types of elements but page-object currently does not. :

text_area(:what, data_test: 'input-what')
...
def search_what(term)
    #self.what = term
    @browser.text_field(data_test: 'input-what').set term
  end
djangofan commented 7 years ago

Ok, this is working for me: text_field(:what, data_test: 'input-what') So, the problem seems to be specific to text_area? I need to spend a little more time on this until I know for sure that this resolves my issue. I will update within the next couple weeks if this solution works for me and I find no other related problems.

titusfortner commented 7 years ago

I believe the only issue is that you were trying to access a text_field with a text_area method. The page-object code looks like it is working as intended here.

cheezy commented 7 years ago

text-area works properly. The HTML you posted above is not a textarea. I'm going to close this issue. If you believe there is still a problem then please feel free to reopen.