Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Can You Write Sample Code For Page Factory Class?

Category: Page Object Model
package pageObjects;


import java.util.List;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindAll;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
import org.openqa.selenium.support.PageFactory;

public class CheckoutPage {
	WebDriver driver;
	public CheckoutPage(WebDriver driver) {
	       this.driver = driver;
               PageFactory.initElements(driver, this);
	}
	
	@FindBy(how = How.CSS, using = "#billing_first_name") 
	private WebElement txtbx_FirstName;

       public void enter_Name(String name) {
		txtbx_FirstName.sendKeys(name);
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *