title: Need some help understanding this Selenium test script example
body: <p>I was reviewing this example and trying to understand how it works. The example is taken from <a href="http://www.tutorialspoint.com/selenium/selenium_page_object_model.htm" rel="nofollow">http://www.tutorialspoint.com/selenium/selenium_page_object_model.htm</a>.</p>
  
  <p>Step1:</p>
  
  <pre><code>package PageObject;
  
  import org.openqa.selenium.*;
  
  public class PageObjectsPercCalc 
  {
     private static WebElement element = null;
  
     // Math Calc Link
     public static webElement lnk_math_calc(WebDriver driver)
     {
        element = driver.findElement(By.xpath(".//*[@id='menu']/div[3]/a"));
        return element;
     }
  
     //Percentage Calc Link
     public static webElement lnk_percent_calc(WebDriver driver)
     {
        element = driver.findElement(By.xpath(".//*@id='menu']/div[4]/div[3]/a"));
        return element;
     }
  
     //Number 1 Text Box
     public static webElement txt_num_1(WebDriver driver)
     {
        element = driver.findElement(By.id("cpar1"));
        return element;
     }
  
     //Number 2 Text Box  
     public static webElement txt_num_2(WebDriver driver)
     {
        element = driver.findElement(By.id("cpar2"));
        return element;
     }
  
     //Calculate Button   
     public static webElement btn_calc(WebDriver driver)
     {
        element = driver.findElement(By.xpath(".//*[@id='content']/table/tbody/tr/td[2]/input"));
        return element;
     }    
  
     // Result    
     public static webElement web_result(WebDriver driver)
     {
        element = driver.findElement(By.xpath(".//*[@id='content']/p[2]/span/font/b"));
        return element;
     }    
  }
  </code></pre>
  
  <p>Step 2: Using above object library to create following test:</p>
  
  <pre><code>package PageObject;
  
  import java.util.concurrent.TimeUnit;
  
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.firefox.FirefoxDriver;
  
  public class PercentCalculator {
  
     private static WebDriver driver = null;
  
     public static void main(String[] args) {
  
        driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get("http://www.calculator.net");
  
        //Use page Object library now
        page_objects_perc_calc.lnk_math_calc(driver).click();     
        page_objects_perc_calc.lnk_percent_calc(driver).click();
  
        page_objects_perc_calc.txt_num_1(driver).clear();
        page_objects_perc_calc.txt_num_1(driver).sendKeys("10");      
  
        page_objects_perc_calc.txt_num_2(driver).clear();
        page_objects_perc_calc.txt_num_2(driver).sendKeys("50");  
  
        page_objects_perc_calc.btn_calc(driver).click();
        String result =  page_objects_perc_calc.web_result(driver).getText();
  
        if(result.equals("5")){      
           System.out.println(" The Result is Pass");
           }
        else {
           System.out.println(" The Result is Fail");
  
           }
        driver.close();
        }
     }
  </code></pre>
  
  <p>Now my question is how "page_objects_perc_calc" object is calling library methods without declaring it as the PageObjectsPercCalc in the second step? Now, if I declare it as below:</p>
  
  <pre><code>PageObjectsPercCalc page_objects_perc_calc = new PageObjectsPercCalc();
  </code></pre>
  
  <p>I get this warning </p>
  
  <blockquote>
    <p>"The static method lnk_math_calc(WebDriver) from the type
    PageObjectsPercCalc should be accessed in a static way";</p>
  </blockquote>
  
  <p>This is correct but I do not know how to define <code>PageObjectsPercCalc</code> object as static. Please help.</p>
  
  <p>Thanks.</p>