title: Cannot Initialize Page Factory in Selenium
body: <p>I face an Issue to Initialize elements </p>
  
  <pre><code>static HomePageFactory HomePageFactory = new HomePageFactory();
  PageFactory.InitElements(Driver.Instance, HomePageFactory);
  </code></pre>
  
  <p>and the throw the below exception</p>
  
  <blockquote>
    <p>Result Message: Test method Form4_Tests.LoginTests.FirstLogin threw exception: System.ArgumentNullException: page cannot be null Parameter name: page Result StackTrace:
    at OpenQA.Selenium.Support.PageObjects.PageFactory.InitElements(Object page, IElementLocator locator, IPageObjectMemberDecorator decorator) at OpenQA.Selenium.Support.PageObjects.PageFactory.InitElements(ISearchContext driver, Object page) at Form4_Framework.HomePage.IsExist() in d:\Test Automation\Form4_Framework\Form4_Framework\HomePage.cs:line 20 at Form4_Tests.LoginTests.FirstLogin() in d:\Test Automation\Form4_Framework\Form4_Tests\LoginTests.cs:line 46</p>
  </blockquote>
  
  <p>1- Where should I initialize page factory (test method , test initialize or class initialize)? and<br>
  2- what if some elements are hidden in page, Can i initialize specific elements?</p>