page-object icon indicating copy to clipboard operation
page-object copied to clipboard

Access to page methods within section

Open brbrr opened this issue 9 years ago • 3 comments

Now sections are threaded as elements with some other elements in it but this approach makes unable to use page methods inside sections: wait_until { login_button? } will raise NoMethodError: undefined method 'wait_until' for Watir::HTMLElement

From stackoverflow:

In the short term, you could work around the issue by calling wait_until directly against the Watir::Browser, which is returned by the page object's browser method:

browser.wait_until { login_button? }

But I think sections should be treated as PageObjects with all related methods

brbrr avatar May 26 '15 13:05 brbrr

Hi. I have run into this issue too. Browser which was used for PageObject initialization is not available in @browser variable ( inside page section class ), but can be accessed with @browser.browser instead. So @browser inside PageSection is actually an instance of Watir::HTMLElement. This seems like a bug that should be fixed.

imankovskyi avatar Dec 05 '17 11:12 imankovskyi

Do you have code to reproduce this?

titusfortner avatar Dec 05 '17 16:12 titusfortner

Yes. I have created minimal example that reproduces it:

page_section.zip

 $ rspec spec/test_spec.rb 
page.ddg_header.browser is: #<Watir::HTMLElement: located: false; {:id=>"header_wrapper"}>
page.ddg_header.browser.browser is: #<Watir::Browser:0x..f958b67bbcb8d8eae url="https://duckduckgo.com/?q=search&ia=web" title="search at DuckDuckGo">
page.ddg_header.browser.browser.browser is: #<Watir::Browser:0x..f958b67bbcb8d8eae url="https://duckduckgo.com/?q=search&ia=web" title="search at DuckDuckGo">
.

imankovskyi avatar Dec 06 '17 22:12 imankovskyi