Example Test Class
1 min
This test class demonstrates how Selenium test scenarios are implemented by extending the shared BaseTest class.
By inheriting from BaseTest, the test class automatically gains access to the initialized WebDriver instance and does not need to handle driver setup or teardown logic.
Test Scenarios
The following test cases are included:
#searchSelenium
- Navigates to Google
- Handles the cookie consent dialog if present
- Performs a search for the keyword “Selenium”
- Verifies that the search results section is displayed
- Asserts that the page title contains the expected keyword
#openAmazonAndPrintTitle
- Verifies that the page title is not empty
- Prints the page title to the console
- Navigates to Amazon
Key Points
- Test classes focus solely on test steps and assertions.
- WebDriver lifecycle management is fully handled by BaseTest.
- Tests are executed using the shared driver instance provided by the framework.
- This structure improves readability, maintainability, and consistency across test classes.