page-object
page-object copied to clipboard
Access to page methods within section
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
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.
Do you have code to reproduce this?
Yes. I have created minimal example that reproduces it:
$ 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">
.