In software engineering, a design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. Rather, it is a template for how to solve a problem that can be used in many different situations.
Few months ago, I read the book Selenium Design Patterns and Best Practices by author Dima Kovalenko. The author has explained various design patterns and best practices that can be used while working with Selenium Webdriver.
It is one of the anti patterns.
Tests in this pattern depends on the execution order of all the tests. Each test is not self sufficient and independent, and thus needs previously run tests to set up the test environment.
Tight coupling is present among the tests
Disadvantages :
Cannot run tests in parallel
A test failed will halt execution of the following test cases
DRY stand for Don’t Repeat Yourself, a basic principle of software development aimed at reducing repetition of information. This principle is stated as, “Every piece of knowledge or logic must have a single, unambiguous representation within a system.”
Advantages :
Modular tests
Reduces duplicate code
Faster code updates as the updation needs to be done at a single place
Disadvantages :
Needs programming skills
Constantly looking for places where this principle can be applied
It states that each test should be completely independent and self-sufficient. Any dependency on other tests or third-party services that cannot be controlled should be avoided.
Advantages :
Modular tests
No tests skip in case any prior test fails
Tests can be run in random order
Can run tests in parallel
Disadvantages :
Time required to write tests increases
Runtime increases as env setup needs to be done before every test. *Designing of test cases take time as test can’t reuse data from other tests
Modern web has many things like social networking buttons, images coming from CDNs, tracking pixels, analytics. All these items can destabilise our tests at any point. Black Hole Proxy takes all HTTP requests going to third-party websites and blocks them, as if the request was sucked into a black hole.
Advantages :
It tries to reduce test instability by getting rid of as many third-party uncertainties as possible.
It helps in reducing test execution time & in increasing test stability.
BDD (Behaviour Driven Development) is an agile testing methodology.
Advantages :
It encourages collaboration between business users, developers and testers.
At its heart, BDD has parameterisation and data tables built in.
Feature files are written in Gherkin language which is quite simple to read & understand by everyone in the team
Disadvantages :
Time Overhead
Structuring all your feature files, scenarios and executable specifications requires some careful planning.
Good communication is required between the person writing the feature files and the person developing the automation code
Locatorsand their methods are separately written for each screen of the UI. Tests are allowed to use these methods, without worrying about the internal implementation.
Advantages :
Code becomes modular
Code becomes reusable (ex SigninPage methods are used in most of test classes)
When any locator changes, refactoring is needed only in its page class
Disadvantages :
Complexity increases (framework needs to be created)
Time consuming
#test-automation #selenium-webdriver #design-patterns #selenium #automation