Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7919615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:55:40+00:00 2026-06-03T15:55:40+00:00

I have a page with URL that is dynamic. Let’s call it view post

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:55:43+00:00Added an answer on June 3, 2026 at 3:55 pm

    You can get the url for the page using the method current_url. On your test above are you trying to determine if you are on the correct page? If that is the case I might suggest using one of the two “expected” methods – expected_title and expected_element.

    The page_url method is more than likely not the choice for you if you need to navigate to a url dynamically. What you might try instead is add a method to your page that does something like this:

    class ViewPostPage
      include PageObject
    
      URL = "site.com/post/"
    
      expected_title  "The expected title"
    
      def navigate_to_post_with_id(id)
        navigate_to "#{URL}/#{id}"
      end
    
    end
    

    And in your test

    on_page(ViewPostPage) do |page|
      page.navigate_to_post_with_id @id
      page.should have_expected_title
    end
    

    Let me know if this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that is generated dynamically via the URL (GET Method). This
I have a defined route that displays a dynamic page: page_show: url: /:domain_slug/:slug class:
I have a uiwebview that sends its loaded page url to a uitableview to
I have an absolute URL, and the URL that a link on that page
I have a functional JSP page that accepts URL parameters and updates a table
I have a page that contains an iFrame point to a URL with parameters.
I have a php page that takes in a bunch of url parameters and
I have a web page, that redirects to the desired destination url using: <meta
I have a long URL on a web page in Windows that I need
I have an edit page with url example.com/product/edit/11 Now if the validation is false

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.