I have a page with a dynamic URL. Let him view the message page. The URL for post is 1 - site.com/post/1, and for post 2 - site.com/post/2.
This is what I am doing at the moment to check if I am on the correct page.
Page:
class ViewPostPage
include PageObject
def self.url
"site.com/post/"
end
end
Cucumber pitch:
on(ViewPostPage) do |page|
@browser.url.should == "#{page.class.url}#{@id}"
end
Is there a better way? Are you even trying to check the whole url or only part site.com/post/?
I am using the latest page-object gem (0.6.6).
Update
An even bigger problem goes directly to the page with a dynamic URL.
Page:
class ViewPostPage
include PageObject
def self.url
"site.com/post/"
end
page_url url
end
Cucumber pitch:
visit ViewPostPage
Now I have to change the Cucumber step to:
@browser.goto "#{ViewPostPage.url}#{@id}"
It would be great if the page knew this identifier, but I still did not understand how to do this.
source
share