While writing scripts for a web application in Eclipse, we have go through several elements. Using xpath/css/id etc., we find the element and then we perform some actions on those elements like clicking, sendkeys etc.
But later, if the path of a particular element gets changed, the our code won’t work. It will throw error ‘Element not found’. So, in that case, we need to change the xpath/css for that element.
But in whole program, it is really difficult to find that element and change the locator there.
So, for ease of coding, we can use “objects.properties” file. This is the file, where we can mention each of the web element we use in the code and give a name for the same. And in code, we will use that name instead of using that locator. So, later when changes needed, we can directly move to the properties file and change. No need to touch other coding stuffs. It makes the code clean and easy.
Here are the steps to follow.
- Open Eclipse and Create a Project there.
- Inside project, create a package.
- Then inside package, create a Java file, where we will write our code.
- Inside Package, create a new file named ‘objects.properties’.
- Mention all elements in this properties file, which is used in our coding.