I have three classes. One for getting all elements from the Webpage, one for performing actions with those elements and one for the test scripts. I get a null pointer except
You can continue to use the @FindBy annotations you just need to make sure you initialise the WebElements. To do this you should initialise your LoginPageElements using PageFactory:
LoginPageElements loginPageElements = PageFactory.initElements(webDriver, LoginPageElements.class);
where webDriver is an instance of the WebDriver you are using to run the selenium tests.
You need to declare the WebDriver
instance and add the constructor in LoginPageElements
& LoginPageActions
class as:
LoginPageElements
class:
WebDriver driver;
//constructor
public LoginPageElements(WebDriver loginDriver)
{
this.driver=loginDriver;
}
LoginPageActions
class:
WebDriver driver;
//constructor
public LoginPageActions(WebDriver loginDriver)
{
this.driver=loginDriver;
}
Let me know if this Answers your Question.