Skip to main content
2 of 3
deleted 26 characters in body
pavelsaman
  • 4.5k
  • 1
  • 14
  • 37

Seeing NullPointerException on running TestNG Selenium Framework

Written the Test Script in TestNG framework where the Open browser activity is happening in "baseClass" under @BeforeTest annotation and the Test Script is written in Test Packages under as @Test Annotation. IN the test Script I am extending the Base Class so that my @beforetest(opening the browser) will work first and then test case functionality should execute. But at TestScript I am getting NULLPointerException. @BeforeTest methods are returning the webdriver object and I thought it will work at @Test methods but this is failing

Can anyone guide me here how to proceed further?

public class BaseClass {
    public WebDriver driver;
    @BeforeTest
    public WebDriver openBrowser()
    {
        System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir")+"/Drivers/geckodriver.exe");
        driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(120));
        driver.manage().window().maximize();
        driver.get("https://app.vwo.com/#/analyze/heatmap/129/reports?token=eyJhY2NvdW50X2lkIjo2LCJleHBlc%20mltZW50X2lkIjoxMjksImNyZWF0ZWRfb24iOjE1MDc3ODk0ODcsInR5cGUiOiJjYW1wYWlnbiIsI%20nZlcnNpb24iOjEsImhhc2giOiJiMzlmMTQ4MWE0ZDMyN2Q4MDllNTM1YzVlNWFjOGVlMCJ9");
        return driver;
    }