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

  • SEARCH
  • Home
  • 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 5971761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:33:45+00:00 2026-05-22T20:33:45+00:00

Could please anybody suggest a way to deal with Inheritance regarding Page Objects pattern

  • 0

Could please anybody suggest a way to deal with Inheritance regarding Page Objects pattern ?

For instance, page objects need to share properties and methods.

public class LoginPage extends SuperPage
public class SuperPage extends LoadableComponent<SuperPage>

This would be Ok. But the problem is that your UnitTests don’t extend SuperPage, they extend TestCase, that holds global properties etc. for Tests.

I try to avoid duplication, because I need to share the same stuff in TestCase and SuperPage… Pages and Tests can extend only one of these.

For instance, I need the same Form Data in PageObjects and Tests available…

Example:

If you have a PageObject for filling out a html form, you need names of the form fields, but you need them even in other pageObjects. So that you extend SuperPage where the field names are. They cannot be supplied from UnitTests, because of this for instance :

@CacheLookup
@FindBy(how = How.ID, using = namespace + signifLvl)
private WebElement sigLvl;
@CacheLookup
@FindBy(how = How.ID, using = namespace + languageTo)
private WebElement langTo;  
@CacheLookup
@FindBy(how = How.ID, using = namespace + languageFrom)
private WebElement langFrom;
@CacheLookup
@FindBy(how = How.ID, using = namespace + description)
private WebElement desc;

But on the other hand, you need to use these in UnitTest methods, because you supply different values from them to PageObjects.

Otherwise it would always by like this, prepopulating PageObjects with variables from TestCase :

@Test
public void doStuff() throws IOException {
    driver.navigate().refresh();
    FillOutFormPage fofp = new FillOutFormPage(driver);
    fofp.fill(some values from TestCase);
    fofp.get();
}
  • 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-05-22T20:33:46+00:00Added an answer on May 22, 2026 at 8:33 pm

    I haven’t done much with WebDriver, but I remember, that most of of the PageObjects I created and tested, didn’t need to be populated. They just contained a scenario – sequence of conditions to be tested, in form of testing methods to be called from UnitTest. The only property to be shared between PageObjects were just a few fields or field names (very exceptionally – like a submit button that when clicked, validation is triggered – it needs to be reachable from all components that forms the entire page and validate something) and namespace for instance.

    In case of creating PageObjects that need to be populated with varying data. It must go from outside (UnitTests). So I guess one should be populating or rather constructing pageObjects with data in unitTests, but only if it is a “service like component” that is needed by others and must be in different that initial state. If you always do it like this, there shouldn’t be a need for sharing this kind of data between TestCase and PageObjects.

    There should be a “boarder” between PageObjects and UnitTests …varying data must come from unitTests into pageObjects testing methods, static data regarding html stay in PageObjects… IMHO

    I don’t recommend having SuperPageObejct because as you have it. SomePageObject.get() method returns SuperObject instead of SomePageObject… What you need in object1, stays in object one. There should be no inheritance. In Object1 there is nothing that you should need from object2.

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

Sidebar

Related Questions

could please anybody share his experience about this topic ? When using jpda on
Can anybody please explain how this could possibly happen? I am completely aware of
Could someone please tell me which objects types can be tested using Regular Expressions
Could someone please explain the best way to connect to an Interbase 7.1 database
could please anybody tell me what is wrong with this regexp ? ((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\\:([0-9]{2,5}) for
Could anybody please help me to write rewriterule, that redirects http<->https (back and force
Could anybody please tell me why i am getting java.text.ParseException: Unparseable date in the
Could anybody please tell me which is best guide/book/material for socket programming in C?
could please anybody help me to install spring surf ? According to this video
Hey, I'm talking about profiles within pom.xml of a project. Could please anybody explain

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.