Closed pgundlupetvenkatesh closed 7 years ago
:/ This does not work ?!
module Pages
module UCP
class Base
.
.
.
#in the step
visit Pages::UCP::Base
@vveliev visit()
and on()
works just fine, the problem is when I use @current_page
after on()
where class is qualified with module namespace.
This works.
class MyCLass1
include PageObject
include PageFactory
text_field(:first_name, id: 'firstName')
button(:save, id: 'saveButton')
end
module MyModule
class MyCLass2
include PageObject
include PageFactory
text_field(:last_name, id: 'LastName')
text_field(:age, id: 'Age')
end
end
# Cucumber step file
When /^I enter details and save the record$/ do
on(MyCLass1).first_name = ‘Pratik’
@current_page.save # This works just fine
on(MyModule::MyCLass2).last_name = 'G V'
@current_page.age = '20' # This doesn't work. Here @current_page has MyClass1 instance
end
Here is the behavior on how @current_page works
https://github.com/cheezy/page-object/wiki/Creating-and-using-page-objects#pagefactory
It seems to update the @current_page instance fine for me though I'm not using it within Cucumber. There could be some strange collision causing an issue for you.
I'm using cucumber and it's working just fine for me, never had any issues.
Will need more info.
Thanks @vveliev and @thamilton2014
I did a sample test on a setup and it's working now. I have to test it on the production code which would take a week or two to kick off. Please do not close this issue, I will get back.
@pgundlupetvenkatesh I'm going to close this issue since you have it working. Please reopen if you find that this is happening in your production code.
I have been using page-object for a while now, recently our automation team had to restructure the framework to qualify each page object model class within module which made @current_page stop working for calling objects. Does PageObject support @current_page on classes qualified with module?
One alternative I found was to have all actions of the page in a block. But, using @current_page was way better to use.