0

While i try to run the below code, i get a failed configuration error like this:

[RemoteTestNG] detected TestNG version 6.14.2 FAILED CONFIGURATION:
@BeforeTest setUp java.lang.NullPointerException

public class Loginpagetest extends Testbase {

    public static WebDriver driver;
    public static Properties prop;

    Loginpage loginpage;
    Homepage homepage;

    public Loginpagetest() throws IOException {
        super();
    }

    @BeforeTest
    public void setUp() throws IOException {
        Intialization();
        loginpage = new Loginpage();
    }

    @Test(priority = 1)
    public void loginpagetitletest() {
        String title = loginpage.validateloginpagetitle();
        Assert.assertEquals(title, "Free CRM software in the cloud for sales and service");
    }

    //@Test(priority=2)
    //public void CRMlogoimgtest() {
    //  boolean flag = loginpage.validateCRMlogo();
    //  Assert.assertTrue(flag);
    //}

    //@Test(priority=3)
    //public void logintest() {
    //  Homepage homepage = loginpage.login(prop.getProperty("username"), prop.getProperty("password"));

    //}

    @AfterMethod
    public void tearDown() {
        driver.close();
    }
}
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • What is `Intialization()` in your code? Where is it defined? – Mate Mrše Jan 14 '19 at 14:38
  • See [What is a stack trace, and how can I use it to debug my application errors?](http://stackoverflow.com/q/3988788/418556) & [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/q/218384/418556) – Andrew Thompson Jan 14 '19 at 15:29
  • Intialization() method which i called from my TestBase class – Veera Raghavan Jan 14 '19 at 16:12
  • public class Testbase { public static WebDriver driver; public static Properties prop; public Testbase() throws IOException { Properties prop = new Properties(); FileInputStream ip=new FileInputStream("C:\\Users\\Hp\\Desktop\\Makaia\\src\\main\\java\\com\\qa\\config\\config.properties"); prop.load(ip); } public static void Intialization() { String browserName = prop.getProperty("browser"); if (browserName.equals("chrome")) { System.setProperty("webdriver.chrome.driver", "C:\\Users\\Hp\\eclipse-workspace\\ – Veera Raghavan Jan 14 '19 at 16:14
  • JeffC can you please tell me on which line my code getting an error I'm unable to fix it.. – Veera Raghavan Jan 14 '19 at 16:33
  • @VeeraRaghavan The exception stacktrace contains line numbers... – Mark Rotteveel Jan 14 '19 at 18:23
  • As you didn't shared stacktrace, It's difficult to get idea where actual issue is? There are 2 possibilities, one is driver not initialized or `browserName` from `String browserName = prop.getProperty("browser");` is null. If that is the case you can use [getProperty(key,defvalue)](https://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#getProperty(java.lang.String,%20java.lang.String)) to avoid null pointer. To get rid of such driver management, resources, configuration and other common issues you should use any open source framework like [qaf](https://qmetry.github.io/). – user861594 Jan 16 '19 at 21:08

0 Answers0