1

I am still unclear why you need Properties file in Selenium. It seems to me that everything stored there can be more effectively store either in Excel or with @DataProvider and @Parameters annotations, so why is Properties file really needed? Also, what is the difference between Properties file and Config file?

3 Answers 3

1

Property and Config file are essentially the same thing except for what is stored in each one.

Config file is typically utilized to vary a configuration of a setup in order to allow the same functionality to exist, but the configuration differs slightly.

Property file is typically utilized to set a bunch of variable properties related to whatever the specific purpose is. This isn't usually "configuration" of the environment, but more parameters for operating specific code interactions.

Selenium is just code libraries, so the question is really more related to how you want to utilize the libraries in a framework in order to execute test automation. I find that property/config files are useful for setting up driver specifics such as screen resolution, driver types, other parameters that may shift depending on criteria of the test execution. I usually keep the maps and keywords in the external data source where there is more modification happening and leave the config file there to govern the "environment" setup for the tests to run on.

The method is totally up to the scripter though and many variations can be utilized and accomplish the same goals.

1

In Selenium .properties files are mainly used to store GUI locators / elements, and also Global fields like database configuration details.

There Is not any built In facility to create object repository. So maintenance of page objects(Page element locators) becomes very hard If you will write all objects of page on code level.'.properties' files are mainly used in Java programs to maintain project configuration data, database config or project settings etc.

Each parameter in properties file are stored as a pair of strings, in key and value format, where each key is on one line. You can easily read properties from some file using object of type Properties.

1

A properties file is just a way to store static data. You could also use a class, database, a plain file or Excel. So you definitely don't need it with Selenium.

The biggest difference between your suggest Excel is that property file can be versioned. Excel is binary format which does not really version readable. Also if you version Excel it might take up a lot more space, therefor it is not practical to use Excel as your test-data store. Keeping your test-data versioned could be very handy if you need to fork the product into multiple versions that you need to test separately.

Personally I would try to store the test-data in object repository like classes, keep the data as close to the code as possible. Unless you have non-technical testers and business-owners that update or extend the test-data. They might not be able to learn version control and how to use an IDE.

A config file is also a data-store, but logically for (environment) configurations. We put something in a config file if we expect someone to change it in a different infrastructure environment for example. Settings that will be changed more often. Calling them a config-file just makes it easier to locate and understand, but I have also seen settings being placed in a config database table.

After all it just boils down to personal preference how to store data that might change frequently.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.