In interview it is frequently asked question that “How To Establish Relationship Between Pages In Page Object Model In Selenium WebDriver”. It is very simple question but generally interviewee confuses. I will explain in a simple way in this post.
What is establishing relations between pages?
Suppose you have two pages, Page A and Page B. When you click on some web element on Page A, it navigates to Page B. So you should create method in such a way that after clicking on web element, it gives you control on Page B. User should not create an object of Page B to access members of Page B.
Take example of DemoQA . In home page it has a link “Registration”. When user clicks on it, user navigates to Registration page. So, you should create a method say “clickOnRegistrationLink” and set a return type as object of Registration page. It is called establishing relationship between pages.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.