How to read property file to the expected data in selenium

426 views Asked by At

I have created Property file and want to read all the Keys and value and need to compare from the expected data. I have created separate class to read all the data from property file but now i am unable to read data to the main class from where i need to compare after running the test.enter image description here

2

There are 2 answers

0
Bhargav Marpu On

Declare a hashmap in your property reader class, load key value mapping in the hash map, update the return type of your method to Hashmap. In the test class call your method and validate

0
Ishita Shah On

You need to Create Structure in order to use config properties values,

Example:

Config.properties file contains: dummyName="Demo"

Config Reader Class who read it, username = prop.getProperty("dummyName"); Where username will be predefined public variable, which store config values And you need to extend variable class, in which variable are defined.

And so on once variable are assigned with properties values, you can use anywhere by extending config reader class.

config.properties
variableLocators
configReader extends variableLocators
TestClass extends configReader