Selenium Web Test Automation Framework Best Practices.

The best practices for Selenium web test automation framework are listed below −

  • Use of dynamic waits like implicit wait and explicit wait instead of using Thread.sleep in the framework to handle sync issues in the application.

  • Usage of Page Object Model framework design to segregate the test scripts from the locators. In case of changes in the webelement properties, test scripts need not be modified only the locators undergo change.

  • Usage of Behavior Driven Development framework. This allows the participation of all members in the agile team to participate in product development.

  • Encourage testing to start from very early phases and in regular intervals of time.

  • Develop a robust framework which supports detailed reporting of the execution results including screenshot capture feature for failure test cases during execution.

  • Before creating the actual test scripts, the requirements should be broken down into smaller scenarios which can be converted to test scripts.

  • Intelligent choice of locators in the framework. In case id, class, name attributes are available for an element, preference should be given to them instead of xpath or css locator.

  • Encourage data driven framework development to execute test cases in multiple combinations of data without increasing test case count.

  • All the test cases should not be executed for all the browsers.

  • It is always recommended to create standalone tests instead of interconnected test scripts.

  • The test case names should be meaningful.