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

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

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