I have created a feature file and then created the selenium base class where i have created a method to read the data from configuration file and then i have given driver details in stepdefiniation class . Then created runner class and executed it .Getting the Null pointer exception in selenium base class . Can you please hep me out on this
//Selenium Base class
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.testng.annotations.Test;
public class SeleniumBaseclass
{
Properties prop;
public void Property()
{
try
{
File f= new File("C:\\Users\\watareuman9\\workspace\\Cucumberproject\\src\\test\\resources\\data\\config.property");
FileInputStream fis = new FileInputStream(f);
prop=new Properties();
prop.load(fis);
} catch (Exception e) {
e.printStackTrace();
}
}
public String getChromepath()
{
return prop.getProperty("ChromePath");
}
public String getAppurl()
{
return prop.getProperty("URL");
}
}
//stepdefination file:
package Stepdfinations;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import cucumber.api.java.en.Given;
public class Accountstepdefinations {
@Given("^I navigated to the Login page$")
public void i_navigated_to_the_Login_page()
{
SeleniumBaseclass b1=new SeleniumBaseclass();
System.setProperty("webdriver.chrome.driver", b1.getChromepath());
WebDriver driver=new ChromeDriver();
driver.get(b1.getAppurl());
}
//@When("^I click on the New Account link$")
//public void i_click_on_the_New_Account_link() throws Throwable {
// Write code here that turns the phrase above into concrete actions
// throw new PendingException();
//@Then("^I should see the New Account registration page$")
//public void i_should_see_the_New_Account_registration_page() throws Throwable {
// Write code here that turns the phrase above into concrete actions
// throw new PendingException();
}
//
//}
//Runner clasas:
package Stepdfinations;
import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
import cucumber.api.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/resources/features")
public class Runner
{
}
//Error appearing as null exception in the following method:
public String getChromepath()
{
return prop.getProperty("ChromePath");
}