Make Selenium Easy

Creating Object Repository In Selenium WebDriver Without Using Any External Data Source

Hello Folks,

We have seen Page Object Model In Selenium. In this post, I will explain a way ( Mostly what I have seen in many selenium frameworks) to design a proper page object model.

It is also asked in interview that if  you have implemented encapsulation and abstraction in selenium framework. This post might help you.

We can achieve encapsulation and abstraction in page object model using this way.  We will declare page objects as private and provide a getter method to access page object.

We will see an example below:

Page Object Class:

Script class:

There might be many other ways of implementing or designing a better page object model. I shared what I have seen and used. If you have any other approach, please let others know as well.

If you have any doubt, feel free to comment below.

If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappySelenium

Table of Contents

Author: Amod Mahajan

A software Tester who is paid to judge products developed by others. Currently getting paid in American Dollars. Writing technical posts and creating YouTube videos are my hobbies.

1 thought on “Creating Object Repository In Selenium WebDriver Without Using Any External Data Source

  1. hi Amod,

    in above code we already entered Username and Password ,may i know why we are entering second time .

    txtEmail.sendKeys(“Amod”);
    txtPass.sendKeys(“Amod”);

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.

Creating Object Repository In Selenium WebDriver Without Using Any External Data Source

by Amod Mahajan time to read: 1 min
1
%d bloggers like this: