title: Execution order of Inherited class and @FindBy class
body: <p>We use <strong>@FindBy</strong> annotation for get web element using Page Object Modeling concept.</p>
  
  <p>e.g.</p>
  
  <pre><code>@FindBy(xpath = "//input[@type='text'][@placeholder='Search']")
  WebElement searchBox;
  </code></pre>
  
  <p>but in order to get <code>searchBox</code> element we need to call <code>PageFactory.initElements(driver, this);</code> first and then after we can perform actions on that element.</p>
  
  <p>I have designed framework accorfing below.</p>
  
  <p><em>Parent Class:</em></p>
  
  <pre><code>import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.support.PageFactory;
  
  import core.driver.WebDriverManager;
  
  public abstract class BasePO {
  
      static {
          System.out.println("Static Block");
      }
  
      BasePO() {
          System.out.println("initElements");
          initElements();
      }
  
      private void initElements() {
          PageFactory.initElements(getDriver(), this);
      }
  }
  </code></pre>
  
  <p><em>Child Class:</em></p>
  
  <pre><code>import org.openqa.selenium.WebElement;
  import org.openqa.selenium.support.FindBy;
  
  public class TestPO extends BasePO{
      @FindBy(css = "input[title='Search']")
      WebElement searchBox;
  
      @FindBy(css = "input[value='Google Search']")
      WebElement searchButton;
  
      public void sendKeys(String inputText){
          searchBox.sendKeys(inputText);
      }
  
      public void clickOnSearchButton(){
          searchButton.click();
      }
  }
  </code></pre>
  
  <p><em>Test Class:</em></p>
  
  <pre><code>import org.testng.annotations.Test;
  
  import core.pageobject.TestPO;
  
  public class TestClass{
      @Test
      public void test123() {
          driver = new FirefoxDriver();
          driver.get("http://www.gsmarena.com/");
          TestPO tpo = new TestPO();
          tpo.search("iphone 7");
      }
  }
  </code></pre>
  
  <p>If I run the test case: <code>test()</code> then according to me executions steps would be:</p>
  
  <ol>
  <li>Firefox driver created [in TestClass]</li>
  <li>Web site will open in firefox browser [in TestClass]</li>
  <li><code>@FindBy</code> annotations would be called first or loaded in memory (I think it's lazy loading) [in TestPO]</li>
  <li>Static Block [in BasePO]</li>
  <li>initElements [in BasePO]</li>
  <li><strong>WebElement</strong> of searchbox can be accessed and <strong>sendKeys</strong> action can be performed on that [in TestClass]</li>
  </ol>
  
  <p>But if I am not correct then when <code>@FindBy</code> annotations would be called and what would be the execution order </p>