validating a POM framework page

How can I validate that in my Page object model framework my page is valid
and my url to load page is up and running.

I need to perform this before instantiating the page class because if I found that my page is invalid / my url is not up then I can return with exception before creating object of my Page Class

Supporter Asked on April 6, 2015 in Selenium WebDriver.

Hi everyone,

This is a mandate thing for all who are using POM in real time in there projects

Any one who can check in there code and see what validations are put to ensure page is correct

on April 7, 2015.
Add Comment
  • 1 Answer(s)

    Amit, It seems that what you are looking for can be done after you do instantiate a page object. PageFactory intializes all the elements to null when it doesnt find the elements of correct page. Use this property and create a method inside the page factory which return you true or false based on if all the elements in the page factory are not null.

    class pageFactory

    public void isPageFactoryValid()
    if(Element1 != null && element2 != null && element3!= null)
    return true;

    return false;



    Professor Answered on April 10, 2015.

    Actually it was an interview question that if we instantiate a page object class then we are actually allocating memory to all the variables of the page object classclass pageobjectlogin{void pageobjectlink1(){ } void pageobjectbutton2(){ }class pagetest {@Test void testcase(){ // here I need to check do I really need this object /* * #Case1 Login url is not working * #Case 2 My current page is not login it is register page but I am initializing login page object */ pageobjectlogin po = new pageobjectlogin();     } }

    on April 15, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.