Please find some of the Quantum best practices to be followed below:
- The use of Given, When, Then and And should be proper and logical.
When you have several givens, whens or thens make it more readable and fluent by using ands and buts
- In the locator files, the keys of the locator values should follow a common syntax so it will be easy to understand what the locator is meant for.
- There should be no duplicates of any locator keys in platform-specific locator files.
- All the selenium code should be written in the Page classes only.
- The step definitions should only have the calls to the Page Class methods.
- Operations on the screen should be kept in separate methods then the validations.
- In the feature or BDD files, the operations on the screens should be stated as When statements and the validations should be kept as then statements.
- Use of static waits should be avoided. Try to kept it minimal and rely more on Wait services.
- If you are performing any clicks on the elements then one can avoid the verification of the same elements as the click command will validate that the element was there on the screen.
- Use of static keyword should be strictly avoided to store webelements/webdriver in variables as it will cause issues in parallel execution. This is because the static class variables will be shared across the threads in Java.
These are some of the standard practices that are recommended to follow. In addition to the above-mentioned practices, all the java based coding practices should be followed.
Related Quantum + CI articles: