Avoid these when writing Selenium Test Scripts

ShreyaBee
2 min readMay 26, 2020

--

Without a well-written test script, Selenium tests are bound to be flaky and ineffective, if not outright impossible to run. A badly written test script creates more work for developers and testers instead of making their lives easier. Here are a few things to avoid when creating Selenium test scripts.

  1. Incorrect use of Waits and Sleeps: If testers mix Implicit and Explicit Waits, it leads to unpredictable wait times or a timeout. Incorrect use of Selenium wait commands results in unstable behavior within tests.
  2. Large test cases with multiple chained assertions: Truly useful Selenium scripts are reusable and easy to maintain. This is quite hard to do if one is writing large test cases that cover large parts of the application under test at one go. The larger a test, the harder it is to identify bugs.
  3. Automating the wrong tests: If automated tests are created for areas that require manual testing, testers have to keep fixing automation code instead of looking for actual bugs in the software. Selenium test scripts are best created and used to automate user functions or processes that are repetitive. For example, every time new code is added to the codebase, regression tests must be run to ensure new code does not corrupt the existing features. A test that requires automation.
  4. Insufficient Test Reporting: Without sufficient reporting and documentation, Selenium tests are bound to fail. Without documentation, the tester will not be able to identify the source of the bug, or which developer created the code in which the bug manifested. Sharing screenshots of the bug is a great practice.
  5. Test on a single browser: Cross-browser testing is absolutely imperative to the success of any website or app. Do the research andcreate a list of browser-device-OS combinations that the target audience is likely to access the software from. Use parallel testing to test on multiple browsers, as well as speed up results.

To create result-driven, sophisticated, and productive Selenium scripts, one must know how to write good test cases. Combine the best practices to create test cases that do exactly what they are meant to with minimal effort for the developer.

--

--

ShreyaBee
ShreyaBee

Written by ShreyaBee

Likes books, cake, tech, tea and sunsets in freezing mountains.

No responses yet