I have a page with URL that is dynamic. Let's call it view post page. URL for post 1 is site.com/post/1
and for post 2 is site.com/post/2
.
This is what I do at the moment to check if I am at the right page.
The page:
class ViewPostPage
include PageObject
def self.url
"site.com/post/"
end
end
Cucumber step:
on(ViewPostPage) do |page|
@browser.url.should == "#{page.class.url}#{@id}"
end
Is there a better way? Do you even bother checking the entire URL, or just the site.com/post/
part?
I am using the latest page-object gem (0.6.6).
Update
Even bigger problem is going directly to the page that has dynamic URL.
The page:
class ViewPostPage
include PageObject
def self.url
"site.com/post/"
end
page_url url
end
Cucumber step:
visit ViewPostPage
What I do now is to change the Cucumber step to:
@browser.goto "#{ViewPostPage.url}#{@id}"
It would be great if there was a way for the page to know it's ID, but I have not figured out yet how to do it.