I have created a login test script and verified home page also but now I have to add new customer and the form accepts following values

  1. Customer Name
  2. Gender
  3. Date Of Birth
  4. Customer Address , city, State and Pin
  5. Customer Mobile No
  6. Customer Email ID and Password.

Following code I have implemented

  WebDriver driver;

  @FindBy(name = "name") WebElement CustomerName;
  @FindBy(xpath = "//input[@value='m']") WebElement Gender;
  @FindBy(name = "dob") WebElement DateOfBirth;
  @FindBy(name="addr") WebElement CustomerAddress;
  @FindBy(name = "city") WebElement CustomerCity;
  @FindBy(name="state") WebElement CustomerState;
  @FindBy(name="pinno") WebElement CustomerPin;
  @FindBy(name="telephoneno") WebElement CustomerMobileNo;
  @FindBy(name="emailid") WebElement CustomerEmailId;
  @FindBy(name="password") WebElement CustomerPassword;
  @FindBy(name="sub") WebElement FormSubmitBtn;

  //Created Constructor of the Class Guru99_AddNewCustomer
  public Guru99_AddNewCustomer(WebDriver driver)
    this.driver = driver;
    PageFactory.initElements(driver, this);

  public void CustomerName( )

but passing values via send keys and passing parameters in method will make my code too long and bulky, I just need to pass sheet Name as we do in Data Driven Framework so that data I'm passing will automatically get filled.

Any assistance will be helpful

Above elements can be found on http://demo.guru99.com/V4


A page object can contain more than just individual web elements and their corresponding functions. For example, a logon page would list the individual web elements through the FindBy's but would not necessarily need to have specific sendkey or click methods (for the button) individually unless you wish to provide those features for lower-level tests. It could simply contain one single logon method, and have that method access the user ID, password, and button.

Using this same line of reasoning, it is often common for page object definitions to contain a "fill the page" type of method, where you could also pass either a list of individual parameters, or in your suggested idea, pass enough information to open and read the list of parameters from another source.

Your Answer

