I am a complete newbie in Selenium and java in general. I am trying to use the Page object model with Page factory to create Page object class for the Login page of an application. I am reading lot of sample code on the web tutorials and there the "Webdriver" reference is delared as "static". Is it that other classes can use the Base class driver instance?
package com.test.login;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class LoginPage {
**public static WebDriver driver = null;**
public LoginPage(WebDriver driver) {
this.driver = driver;
PageFactory.initelements(driver, this);
}
@FindBy(xpath = "//input[contains(@id,'username')]")
public WebElement User_ID
@FindBy(xpath = "//input[contains(@id,'password')]")
public WebElement Password;
@FindBy(xpath = "//input[contains(@id,'login')]")
public WebElement Login_Button;
LoginTestClass.java
public class LoginPageTest{
WebDriver driver;
LoginPage loginpage = PageFactory.initElements(Login.class);