0
     //Reading data from property file :

      String username = prop.getProperty("username");
      String password = prop.getProperty("password");
           @Test
public void testValidCredentials()  {
obj.loginAs("username","password"); 

}

public HomePage loginAs(String username, String password) {

    driver.findElement(By.id("id1")).sendKeys(username);
    driver.findElement(By.id("id2")).sendKeys(password);
    driver.findElement(By.id("id3")).click();
    return new HomePage(driver);

}

What i was trying to do is pass username and password to loginAs method but however when i pass it inserts as Email as Username and password as password instead of what i read from my property file. Property file : username = r@t.com password = 1234

user1511808
  • 65
  • 1
  • 3
  • 7

1 Answers1

2

Problem might be in this line

obj.loginAs("username","password"); 

change it to

obj.loginAs(username,password); 

that is username, password without quotes.

Prashant Shukla
  • 1,391
  • 9
  • 18