This is an Automation project using the new features for Selenium Webdriver 4.11 version.
This project has been developed by Douglas Urrea Ocampo to improve learning on advanced Automation testing with Selenium 4.11.
The main features of this project has the following:
- You find the latest and greatest features and techniques for Selenium 4.11 to improve your testing!
- Page Object Model (POM) as a design pattern for creating an Object directory for web UI elements.
- Use industry-standard best practices for writing tests with Selenium 4.11.
- The re-usability of code to avoid unnecessary data exposure to the user by using the abstraction.
- JUnit as framework for writing test automation tests for Java programming language.
- Selenium Webdriver that supports comprehensive Web Tests.
⚠️ Disclaimer⚠️ This project has an educational objective: To learn the newest features for Selenium 4.11.
Some practices will help you to improve your test architecture, but the central point of this repository is demonstrate with examples the new and exciting features of Selenium 4.11.
You can find more information about the new features with the official links:
- Name:
Douglas Urrea Ocampo
- Country:
Colombia
- City:
Medellin
- E-mail:
[email protected]
- LinkedIn: https://www.linkedin.com/in/douglasfugazi
- Contact: https://douglasfugazi.co
This project using the following languages and frameworks:
- Java 11 as the programming language
- JUnit as the UnitTest framework to support the test creation
- Selenium WebDriver as the web browser automation framework using the latest 4.11 version
- AssertJ as the fluent assertion library
- Log4J2 as the logging management strategy
- Owner to minimize the code to handle the properties file
- Project Lombok as fully featured builder library
- Java Faker allows us to generate fake data
We know that any automation project starting with a good test architecture.
This projects has UI Tests using Selenium Webdriver with latest 4.11 version.
The website under test is an e-commerce website here to test different domain access according to the scope of each test.
I must say it was fun learning and automating this website because it was challenging in some respects. 😀
- Browser is Microsoft Edge in order to have a different approach to test.
- Test has following scenarios:
- Scenario 1:
- How To Use Chrome DevTools Protocol (CDP) In Selenium 4.11
- DevTools: Console Logs
- Geolocation
- Network Emulation: 3G, 4G, Wi-Fi, Bluetooth
- How To Use Chrome DevTools Protocol (CDP) In Selenium 4.11
- Scenario 2:
- How To Use Element Position In Selenium 4.11
- Element Position of an Image using built-in method 'getRect()'
- Size & position to fetch the width & height of an element.
- How To Use Element Position In Selenium 4.11
- Scenario 3:
- How To Use Relative Locators In Selenium 4.11
- Each relative locator is a method to be searched by: Above, Below, Left, Right, Near of.
- How To Use Relative Locators In Selenium 4.11
- Scenario 4:
- How To Take Screenshots In Selenium 4.11
- Method 'getScreenshotAs' is used to take a WebElement screenshot.
- Method 'getFullPageScreenshotAs' is used to take a Full Page screenshot.
- How To Take Screenshots In Selenium 4.11
- Scenario 5:
- How To Use Window and Tab Management In Selenium 4.11
- Scenario 6:
- How To Use Wheel Scrolling with Actions Class In Selenium 4.11
- Scenario 7:
- How To Use CDP command to capture Performance Metrics In Selenium 4.11
- Time to First Byte (TTFB): To identify when a web server takes too long to respond to requests.
- First Contentful Paint (FCP): First time in the page load timeline when the user can see anything on the screen.
- Largest Contentful Paint (LCP): It denotes the point in the page load timeline when the page's main content has most likely loaded.
- First Input Delay (FID): It quantifies the experience users feel when attempting to interact with non-responsive pages.
- Time to Interactive (TTI): It helps identify cases where a page appears interactive but is not.
- Total Blocking Time (TBT): It helps quantify the severity of a page's non-interactivity before it becomes reliably interactive.
- Cumulative Layout Shift (CLS): It helps in quantifying how frequently users encounter unexpected layout shifts.
- How To Use CDP command to capture Performance Metrics In Selenium 4.11
- Scenario 8:
- How To Simulate Devices Viewport In Selenium 4.11
- Google Chrome
- Firefox
- Microsoft Edge
- Internet Explorer 11
- Safari
- Opera
- iPhone X
- iPhone SE
- iPad Pro
- Galaxy Note 10
- Galaxy Tablet
- Pixel 6 XL
- OnePlus 10
- How To Simulate Devices Viewport In Selenium 4.11
- Scenario 9:
- How To Simulate Network Interception In Selenium 4.11
- Network Security to intercept network requests and block requests based on the conditions.
- Network Block Patterns to block URLs and requests patterns.
- WebSocket Listener to intercept WebSocket requests.
- Event Message Listener to intercept source events.
- Intercept HTTP traffic and responses.
- Request Cache to intercept requests served from cache.
- Response Override to intercept responses served from cache.
- How To Simulate Network Interception In Selenium 4.11
- Scenario 1:
- After the test, assertions will be validated to each test.
- Annotation @Test will be used to group the tests by Smoke and Regression tests.
- Each tests will finish automatically and the browser will be closed.
New Scenarios:
- Practice Test:
- First Approach: Test the Register Account page.
- Verify the error messages count and red alert text without filling the Register Account Form.
- Negative test cases.
- Second Approach: Test the Register Account page with Page Object Model (POM).
- Parameterized test with MethodSource to perform the test for each field and do assertions.
- Negative test cases.
- Third Approach: Test the Register Account page with Page Object Model (POM) and Data Driven.
- Precondition Scenario: Load the Test Data to perform the Register Account page.
- Test to verify that the user is able to Register an Account.
- Assertions to each field.
- First Approach: Test the Register Account page.
- Accessibility Testing: Perform accessibility test on the website under Test.
- The test will display in logs if there are any accessibility rule violations.
- Download the latest Java JDK from here
- Install git from here
- Selenium Webdriver from here
- Install Apache Maven from here
- Test Runner is JUnit 5 from here
- Build Tool is Maven the latest version
- Note: ChromeDriver.exe is not necessary, you should use the Selenium Manager capabilities.
- Note: POM.xml has all configuration installed, you should use the Maven build tool only.
- Download the project from GitHub
- Option 1:
git clone https://github.com/fugazi/carbonlibre-ui-api-selenium.git
- Option 2: Download it as a Zip file and extract it
- Option 1:
- CD into the
Carbon Four > carbonfour-selenium-4
folder - Set up Maven
- Run the following command in the terminal:
- Option 1:
mvn clean
- Option 2:
mvn clean package
- Option 1:
- Run the following command in the terminal:
- Running Tests in the project
- Option 1: run
mvn clean install
in the path of the project - Option 2: Open the project baseline and run each Selenium Test:
src/test/java/Selenium_4_Tests
- Option 1: run
- Enjoy the project! 😎
This project uses Allure Report to automatically generate the test report. There are some configuration to make it happen:
- aspectj configuration on
pom.xml
file allure.properties
file onsrc/test/resources
You can use the command line to generate it in two ways:
mvn allure:serve
: will open the HTML report into the browsermvn allure:report
: will generate the HTML port attarget/site/allure-maven-plugin
folder
- Selenium project Baseline:
Carbon Four
- Project package
Selenium_4_Tests
into foldersrc/test/java/Selenium_4_Tests
- Selenium UI Tests
Test.java
into foldersrc/test/java/Selenium_4_Tests
- Page Objects
CategoriesPage.java
into foldersrc/test/java/Selenium_4_Tests/Pages
- Screenshots package
Selenium 4/Screenshots
into foldersrc/test/java/com.selenium_4/Screenshots
- New Scenarios Selenium 4.0 Test Practices into folder
src/test/java/Selenium_4_Tests_Practice
- Project package
- testName:
carbonfour-selenium-4
- Display dependencies updates:
mvn versions:display-dependency-updates
- Update properties:
mvn versions:update-properties
- If you have an idea, suggestion, feature or an issue, please open a new Pull Request on GitHub
- Pull requests without explanations will be rejected. No hard feelings, we are open to all suggestions.