maven - Unable to find property file Java and TestNG -


already tried solution no luck yet :

cannot load properties file resources directory

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 :

http://prntscr.com/g1bpq2

upate :

  1. it works when removed .properties extension filepath.
  2. 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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -