Have below Selenium Program using Object Repository Library File but the same is failing and shows java.lang.NullPointerException. Have commented the specific syntax lines as "error". Also attached the error screenshot and config.property files.enter image description here. Have tried to identify the cause but could not. please clarify the cause of the failing and error message.
package objectrepository;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;
import objectrepository.Lib_ChromeDriver;
public class OBRClass_2 {
@Test
public void launch_chrome() throws Exception{
Lib_ChromeDriver LCD = new Lib_ChromeDriver();// Lib_ChromeDriver is the Object Repository Library File
System.setProperty("webdriver.chrome.driver", LCD.Path());// error shown
WebDriver Snap = new ChromeDriver();
Snap.get(LCD.AppURL());
}
}
and:
// a Java Class containing Constructor & method and is saved as Library file.
// Constructor has will call the ObjectRepository File and
// method will call the Call the ChromeDriver Location to Launch the same
// this Library Class can be called in Selenium program to launch the Chrome Driver
package objectrepository;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import org.testng.annotations.Test;
public class Lib_ChromeDriver {
Properties Prop;
@Test
public void Lib_ChromeDriver() throws Exception{// Constructor calling the Object Repository File
File OB_File = new File("./Config/Config.property");
FileInputStream OB_FIS = new FileInputStream(OB_File);
Prop = new Properties();
Prop.load(OB_FIS);
}
public String Path() throws Exception{// method calling the ChromeDriver Path to Launch the same
String ChromePath = Prop.getProperty("ChromeDriver"); // error shown
return ChromePath;
}
public String AppURL() throws Exception{
String AppURL = Prop.getProperty("URL");
return AppURL;
}
}