There is no need to include PageObject in widget class. The full answer is here https://github.com/cheezy/page-object/issues/173
Accessing to JS-widget from module
-
13-04-2022 - |
Question
I try to access to custom JS-widget from my module. Base page class just include PageObject, DataMagic and RSpec::Matchers.
My class
require_all 'lib/pages/billing/billing_form_panel.rb'
class RealtyCpBillingPage < BasePage
include BillingFormPanel
end
Module
require_all 'lib/widgets/jquery_datepicker.rb'
module BillingFormPanel
include PageObject
button :show_datepicker, class: 'ui-datepicker-trigger'
jquery_datepicker :datepicker, id: 'ui-datepicker-div'
def datepicker
datepicker_element
end
def select_packet data
if data['date']
show_datepicker
data['date'] = data['date'].split(' ').reverse
datepicker.year = data['date'][0]
datepicker.month = data['date'][1]
end
end
end
JQuery UI datepicker widget
class JQueryDatepicker < PageObject::Elements::Div
include PageObject
PageObject.register_widget :jquery_datepicker, JQueryDatepicker, :div
def month month
select_list_element(class: 'ui-datepicker-month').select month
end
def year year
select_list_element(class: 'ui-datepicker-year').select year
end
end
And steps:
Если(/^если выбираю тариф:$/) do |table|
on(RealtyCpBillingPage).select_packet table.hashes.first
end
When run this test, I see the following error:
Unable to pick a platform for the provided browser (RuntimeError)
./lib/pages/billing/billing_form_panel.rb:22:in `datepicker'
./lib/pages/billing/billing_form_panel.rb:34:in `select_packet'
So, How can I access to that Widget from my Module?
UPD: Browser start here hooks.rb
.
Before do
@browser = Watir::Browser.new :firefox
@browser.driver.manage.timeouts.implicit_wait = 8
end
After do
@browser.close
end
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow