I'm a beginner in testing. I am working in selenium with page object design pattern. I want to keep the test data separately but I'm still confused. I want to know the difference between the usage of the properties file, YAML, and JSON.

Is there any reason why I should use one of these file types for my test data? Does Selenium support one type of file for data better than the other types?

  • 1
    I've edited your question to be less opinion-based. Asking people what they prefer is not a good format for questions here - we're looking for questions that can have a correct answer. – Kate Paulk Jan 31 '17 at 12:45

YAML is designed to be used by all programming languages:

YAML is a human friendly data serialization standard for all programming languages.

JSON originated in the JavaScript world and is mostly used as data format between back-ends and JavaScript web-front-ends.

JSON (JavaScript Object Notation) is a lightweight data-interchange format.

In the end it doesn't really matter which format you use. I would pick the one the team has the most experience with.

  • What is your opinion about properties file to keep the test data ? – toastmaster Jan 31 '17 at 9:38
  • I rather keep test-data in my code, but it greatly depends on how much data it is. Some data would be better in a database, some better in a config file, for most test-data I would create a test-data class which contains the necessary data. – Niels van Reijmersdal Jan 31 '17 at 9:51
  • An example would be an user object which contains multiple users with their settings/rights. In code I would use something like adminuser = new user(admin), login(adminUser), in the login function it would use user.password to get the data. Instead of login(getConfigFileUserData('admin').username, getConfigFileUserData('admin').password). My preference is that code should read like a story, readability is my highest priority, where the data is stored I could care less about. – Niels van Reijmersdal Jan 31 '17 at 9:51

Properties file is a great option for scale-able test automation framework. You can keep data in key=value pairs. Anyone with limited technical expertise can easily add/remove properties without messing the format. Reading properties file in Java is considerably easy with Properties class or File reading libraries.

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