Reputation: 31
I am trying to use the PageObject
design pattern with my Selenium testing, and I have the following set of Page classes:
PageObject
base class, which keeps track of the WebDriver and site's base URL. It also has private WebElement
resources which show up on every page in the site, e.g. the menu bar and side bar links. There are public methods to access these resources, e.g. to login and logout.UserRolePage
classes which extend PageObject
. Depending on the role of the logged in user, these classes have other private WebElements
which persist on each page once the user is logged in. There are public methods to access these resources as well.UserLandingPage
) which extend the UserRolePage
classes. These have their own page-specific WebElements
and actions.When I create a new UserLandingPage
using the method:
UserLandingPage userLanding = PageFactory.initElements(driver, UserLandingPage.class);
which WebElements
get populated? Just the ones which are visible to the UserLandingPage
class, or does PageFactory
somehow look at all the base classes and populate those WebElements as well?
Upvotes: 3
Views: 1747
Reputation: 26
All the visible fields that you have annotated will be initialized to the associated web elements.
Upvotes: 1