I am practicing for java selenium and end up getting the following issue when i try to enter the email id in the mentioned url.Please help to fix the issue
java.lang.NullPointerException
at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:69)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38)
at com.sun.proxy.$Proxy14.sendKeys(Unknown Source)
at practice.pagesui.Firstpage.launchurl(Firstpage.java:79)
at practice.pages.Firstpagefixture.user_select_Email_ID(Firstpagefixture.java:38)
at ✽.Given User valid_Email_id(Features/Frontpage.feature:4)
What I have tried:
public class Firstpage
{
public WebDriver driver;
public Firstpage(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
@FindBy(xpath = "//input[@id='inputEmail']")
WebElement Email;
UIutilitytest Helpers=new UIutilitytest();
public void launchurl() throws Throwable
{
driver=Helpers.getdriver();
driver.get("https://phptravels.org/clientarea.php");
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.manage().window().maximize();
Email.sendKeys("sa@gmail.com");
}
}
Helpers class :
public class UIutilitytest {
public WebDriver driver;
public WebDriver getdriver() {
String exePath = "C:\\Users\\Desktop\\Test\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver",exePath);
driver = new ChromeDriver();
return driver;
}
public class Firstpagefixture
{
public WebDriver driver;
@Given("^user_select_Email_ID$")
public void user_select_Email_ID() throws Throwable
{
Firstpage firstpg=new Firstpage(driver);
firstpg.launchurl();
}
}