I am using Faker class to create random values in Selenium Webdriver automation. Below is the class for your reference.
public class NewUserFormAction {
Faker faker = new Faker();
public String name = faker.name().firstName();
public String Surname = faker.name().lastName();
public static void Execute(WebDriver driver,List<HashMap<String,String>> map) throws Exception{
WebDriverWait wait = new WebDriverWait(driver,10);
wait.until(ExpectedConditions.elementToBeClickable(NewUserFormPage.gender));
NewUserFormPage.gender.click();
NewUserFormPage.customer_firstname.sendKeys(name);
NewUserFormPage.customer_lastname.sendKeys(Surname);
}
}
when I am executing this code I am getting exception at compilation at below steps with error can not make static method reference to non static data member.
NewUserFormPage.customer_firstname.sendKeys(name);
NewUserFormPage.customer_lastname.sendKeys(Surname);
Here I understand the faker instance is create on public class which is non static and it is being called in Execute method which is static. Can you please help me how to solve this issue ?