maven - Unable to find property file Java and TestNG -
already tried solution no luck yet :
my code:
protected webdriver driver; public static properties prop; @beforesuite public void setup() { chromeoptions options = new chromeoptions(); options.addarguments("--disable-notifications"); system.setproperty("webdriver.chrome.driver","e:\\chromedriver.exe"); driver = new chromedriver(options); //calling property file function here readdata(); driver.get(prop.getproperty("url")); } public void readdata() { prop = new properties(); try { prop.load(new fileinputstream("d:\\projectname\\src\\main\\resources\\datafile.properties")); } catch (ioexception e) { e.printstacktrace(); }}
getting exception :
java.io.filenotfoundexception
file there , have tried lot of diff. file path full path, path starts src
ect.
project structure :
upate :
- it works when removed
.properties
extension filepath. - still not sure why intellij did not add file extension .properties. because sure have created file type
properties
.
here answer question:
instead of :
prop.load(new fileinputstream("d:\\projectname\\src\\main\\resources\\datafile.properties"));
can try:
prop.load(new fileinputstream("./src/main/resources/datafile.properties"));
let me know if answers question.
Comments
Post a Comment