For some reason, when I call method Spage.editExButton(int ID), I get an error saying that WebElement first is null. Why is it null? I have defined it using the @FindBy annotation. I have to explicitly define the element using findElement(By.id("xxx")) in order to be able to click on it. But why am I unable to call it using the @FindBy notation?
public class SPage extends GPage<SPage> {
public SPage() {
super();
}
public SPage(String pageType) {
super(pageType);
}
@FindBy(id = "xxx")
WebElement first;
public WebElement eButton(int ID) {
first.click();
String tmp = ID + "-Edit";
WebElement edit = getDriver().findElement(By.id(tmp));
return edit;
}
public EPage cEdit(int ID) {
eButton(ID).click();
return new EPage(getBasePageType()).openPage(EPage.class);
}
}
I am calling the method like this:
static EPage epage;
static SPage spage;
@Test
public void edit_exception() {
epage = spage.cEdit(IDbefore);
}
WebElement firstso by default itsnullthrowingNPEforfirst.click();- SmitSPage? Is it given to you by Selenium? - Sotirios Delimanolis