Home > Agile, BDD, C#, Selenium, Test Automation > Page-Object pattern for creating a Test Automation Framework

Page-Object pattern for creating a Test Automation Framework

Page-Object pattern is one of the most effective approaches for creating a Test Automation Framework. This pattern maps a GUI page to a page class and the functionality to interact about the page is captured within the Page class (i.e., a new page class created for each new web page). So, you are calling the page class methods that perform action on the web page in your tests.

Test maintenance becomes easier by creating a Base Page class as it contains most common functions that need to be performed on any web page. For example: If need to navigate to a webpage in many of my tests, I may define this in my Base Page Class and then my Page Class must inherit this.

Advantages of using Page-Object pattern in Selenium:
  • Test code is easily readable.
  • Distinguished reusable code.
  • No duplication of Selenium API calls.
  • Creation of tests are easy and improves maintainability.
  • Used effectively with IDE such as Visual Studio, Eclipse, IntelliJ, Visual Studio.
  • Excellent support for languages such as C#, Java, Ruby, Python, Perl.
Advertisements
  1. Prasanna
    August 17, 2012 at 6:45 am

    Can you please implement the Webbrowser class which is used in base Page since i am trying to implement your framework

  2. January 29, 2013 at 1:10 am

    I really enjoy every thing penned, it’s a fantastic piece of writing and your meaning is a great one. I look forward to discussing this with some friends and family that I know will be fascinated.

  3. May 22, 2013 at 2:42 am

    Excellent article. Keep writing such kind of information on your site.

    Im really impressed by your site.
    Hey there, You have performed an excellent job.
    I’ll definitely digg it and individually suggest to my friends.
    I am sure they will be benefited from this site.

  4. August 1, 2013 at 12:12 pm

    Hi there! This blog post couldn’t be written any better! Going through this article reminds me of my previous roommate! He always kept preaching about this. I most certainly will forward this post to him. Fairly certain he’s going to have
    a great read. Thanks for sharing!

  5. January 29, 2014 at 5:03 pm

    I really love the page object pattern as the right abstraction to do surface tests, but I really don’t like seleniums implementation of that pattern, cause I have to write to much boilerplate code and don’t have the flexibility I need. So I created another framework based on Webdriver that lets you create PageObjects just by annotating interfaces: http://popperfw.org

    Maybe you want to take a look at it. I would be glad about feedback.

  6. September 5, 2014 at 3:04 am

    Definitely consider that which you stated. Your favourite justification appeared to be
    on the net the easiest thing to take into account of.
    I say to you, I definitely get annoyed at the same time
    as other folks think about worries that they plainly do not
    understand about. You controlled to hit the nail upon the
    highest and also defined out the whole thing with no need side effect , other people can take a signal.
    Will likely be back to get more. Thank you

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: