page_url

How to get page_url value in ruby page-object gem

TL;DR

In this short post I will provide code example for undocumented page-object gem feature, how to get value of page object page_url attribute in page object instance.

If you do browser test automation, I advise you to use following software stack:

  • Ruby language
  • selenium-webdriver gem
  • watir-webdriver gem
  • page-object gem
  • cucumber

 

And most of your code base should be written in cucumber feature files, step definitions and page definitions using page-object framework. Doing that, your code base will be highly maintainable, readable and DRY.

All of mentioned frameworks are open sourced, and they do not document all of their features (although I am very satisfied with the documentation). Sometimes you need to dive in source code and spec tests of those frameworks.

Page object gem has a lot of useful helper methods at your disposal. page_url returns page url that is defined in class definition. For example:

But in page-object gem wiki page there is no example how to actually get page_url value.

To save your time browsing through gem code base, here is how you can do that:

 

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Leave a Reply

Your email address will not be published. Required fields are marked *