I have a class called ReqOrderImpCode with the following code inside it:
`public class ReqOrderImpCode {
WebDriver driver;
WebDriverWait wait;
PrintStream out;
int maxim = 0;
boolean bcase = true;
//Constructor
public ReqOrderImpCode(WebDriver driver, WebDriverWait wait, PrintStream out) throws FileNotFoundException {
this.driver = driver;
this.wait = wait;
this.out = out;
}
// Start testing, initialize the page
public void page() {
driver.get("http://google.com");
driver.manage().window().maximize();
}
//Access to methods
Methods m = new Methods(driver, wait, out);
public void checkLoginAndProceed() throws FileNotFoundException {
String pageTitle = driver.getTitle();
if (pageTitle.equals("GAS")) {
m.sendKeys(xUsername, "ftalexiuc");
m.sendKeys(xPassword, "1freedom1");
m.click(xLogin);
}
}`
The methods class which i am using to call the methods above looks like this:`
public class Methods {
//Initialization
WebDriver driver;
WebDriverWait wait;
PrintStream out;
//Constructor
public Methods (WebDriver driver, WebDriverWait wait, PrintStream out) throws FileNotFoundException {
this.driver = driver;
this.wait = wait;
this.out = out;
}
//Method for clicking
public void click(String s){
WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(s)));
element.click();
}
//Method for SendKeys
public void sendKeys(String s, String t){
WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(s)));
element.sendKeys(t);
}
}`
The problem is that the m.sendKeys() method from the first class is returning NullPointerException error. How should i write this for this error to be avoided and my code to run as intended?