Learn about Locator using in Selenium automation testing
Element locators are an important factor in determining the stability of an selenium automation testing script. Many new guys often don’t care much about getting the locator efficiently, but just let it run at that moment.
However, just because an XPath works right away doesn’t mean it will work fine later. Especially when there is a small change on the application and affects the structure of XPath.
Investing time to learn about locator, about supported locator types, relative – absolute XPath & optimal XPath will help a lot and also reduce the time to revise later.
Finding and fixing XPath in particular or locator in general is a tedious and time consuming job.
Preparation test data
The preparation of test data (also known as the Pre-Conditions step) is also an important thing. Most of the script errors are caused by the locator, the rest is about test data. Many of tester often use available data for testing and do not prepare data themself.
For example, when testing the search function, randomly select a product name to search. However, this way is only temporary and carries many risks, because after a while the product name is changed, deleted by another person, and then the script will not find the product and return the result fail.
Creating a data for testing will help us control the condition and ensure that we always have the right data, for example, in the scenario above, instead of randomly choosing a product name, creating a new product in advance to get the necessary data.
Test data recovery in selenium automation testing
Recovery of test data (Post-Conditions) is as important as preparation, for example, after performing a test case to change the password of an account successfully, we must take a step to restore the old value. so that other tests that use the account (or that data in general) are not affected, similar to changing the permissions and status of the data to be tested.
There are some ways to restore data after running selenium automation testing script : Use API after test, run query SQL after test, use UI for restore, snapshot and restore DB..
Dependencies between test cases
The tests should not depend on each other, or in other words it should be independent.
For example, I have 3 testcases, then these 3 testcases should be independent of each other, if only one of the three is taken out, it will still be able to run, avoiding that the tests depend on each other and when running separately, the error is incorrect. If there is a constraint, it should be prepared as a precondition.
Dependencies lead to problems if one test fails, affects other tests behind.
The post today share with you 4 things to keep in mind in the beginning phase with Selenium automation testing, it may take a bit more time to learn but it is worth it and helps a lot especially when you will be involved in a project. Thank you for watching.