I've got a question. What is a difference between:
@FindBy(id= "submit-button")
WebElement submitButton;
public void submitClick() {
submitButton.click();
}
and
@FindBy(id= "submit-button")
WebElement submitButton;
public WebElement submitButton() {
return submitButton;
}
public void submitClick() {
submitButton().click;
}
Is getter needed using PageFactory? If yes, why we should use it? It is not just handled by initelements method?
Getters are used to expose
private
variables to other classes.If you declare
submitButton
asprivate
(as you should, it's a class member as any other class variable you declare) it can be used only in the current class. If you use it only in the current class (as you should, the button should be part of this page object alone) there is no need for getter.