here is the code which im writing using POM… I have created Page and test cases, but when im running the code , its throwing the nullpointer exception error… My appliction get launch on my device but @Test get failed…
PAGE :-
// This class will store all the locators and methods for login page
package com.pb.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class Loginpage {
WebDriver driver;
By mobilenumber = By.id("......");
By submit = By.id(".......");
public void LoginPage(WebDriver driver) // Create Parametrized Constructor to intialize the Webdriver
{
this.driver = driver;
}
// Create Method to login by calling above locators .
public void LoginToPb(String number) {
driver.findElement(mobilenumber).sendKeys(number);
}
public void clicktologin(){
driver.findElement(submit).click();
}
}
TESTCASE
public class VerifyPbLogin {
AndroidDriver<MobileElement> driver;
@BeforeClass
public void launch() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "EBAZFG240031");
capabilities.setCapability("version", "4.4.2");
capabilities.setCapability("appPackage", "........");
capabilities.setCapability("app_activity",
"...................");
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
System.out.println("timecheck");
}
@Test
public void verifylogin() {
Loginpage login = new Loginpage();
login.LoginToPb("xxxxxxxxxx");
login.clicktologin();
driver.quit();
}
}