- This repo has example codes with Selenium 4 features.
- Websites used for testing are: automationpractice.com, saucedemo.com, the-internet owasp-juice-shop and LambdaTest E-Commerce Playground
- This repo uses
Maven
as build tool andTestNG
testing framework to run the tests.
- I have tried to answer the below questions by providing working code example in this repo:
- How do I select a value from Table?
- How do I tick and untick checkboxes using selenium
- How do I right-click using selenium?
- How do I drag and drop using selenium?
- How do I write code to log in and logout using Selenium?
- How do I pass multiple test data value using DataProvider in tests?
- How do I mouse hover an element using selenium?
- How do I download a file using Selenium?
- How do I upload file using selenium?
- How do I press keys using selenium?
- How do I work with multiple Tab windows in selenium?
- How do I work with iFrames using Selenium?
- How do I double-click using Selenium WebDriver?
- How to check for chrome generated logs when selenium tests are run?
- End-to-End tests for Juice Shop Website are running on
http://localhost:3000
inside the container in GitHub actions. - GitHub Actions is used for setting up CI/CD Pipeline
- User will navigate to the website and close all the pop-up first.
- User will click on Login link and click on
Not yet a customer link
and register himself on the website. - Once the Registration is successful, User will Log in with that username and password.
- After successful Login, User will Add AppleJuice and BananaJuice to the Basket.
- After asserting the messages for items added to basket, user will check for the count of items displayed on top
of
Your Basket
link. - User will click on
Your Basket
link and check the order details and click on Checkout. - User will enter a new Address for Delivery and select it to process further.
- User will continue further to Card for Payment and select the card added to make payment.
- On the Order Summary page, user will verify all the details like Name, Address, Order details and total amount to be paid and place order.
- User will re-check the details on Order confirmation page and check for
Thank You
message order confirmation and delivery message.
- The User will navigate to the website.
- From the Home Page of the screen, user will navigate to the Registration Page and register himself. Verification will be done by asserting the registration successful message.
- User will click on the Shop by Category option on the top left and select a category for selecting the product to purchase.
- From the Product Page, the user will hover on any product which he likes and select the Add to cart option. Once a product is added to cart, assertions will be performed to check the success message displayed.
- On the Checkout page, user will provide the billing address details and also assertion will be made for product name and its respective price.
- Once a product is checked out, the user lands on the Order Confirmation page, where product name, price and shipping address will be asserted and after that Order would be marked as confirmed.
- Finally, an Order confirmation message would be verified in the tests which marks the end of the test journey.
-
Start
Juice-Shop
website locally, for doing this we will make use ofdocker-compose-v3-juiceshop.yml
which is available in the root folder of this project. -
Open terminal/command prompt and navigate to the root folder of the project and run the following command:
docker-compose -f docker-compose-v3-juiceshop.yml up -d
-
Once the
Juice-Shop
website is up and running, we are good to run the end-to-end tests using the juice shop website. -
There are 2 ways to run the tests, those are as follows:
- Right-Click on the
test-suite\testng-juice-shop.xml
and selectRun ...\test-suite\testng-juice-shop.xml
-
To run the tests in headless mode update the value for
headless
property variable totrue
mvn clean install -Dsuite-xml=test-suite\testng-juice-shop.xml -Dheadless=true
-
To run the tests without headless mode(to see the test running in browser) update the value for headless property variable to
false
mvn clean install -Dsuite-xml=test-suite\testng-juice-shop.xml -Dheadless=false
- Right-Click on the
-
Stopping the Juice Shop website running in local
docker-compose -f docker-compose-v3-juiceshop.yml down
-
Start the Selenium Grid in local using the
docker-compose-v3-seleniumgrid.yml
file. -
Run the following command:
docker-compose -f docker-compose-v3-seleniumgrid.yml up -d
This will start the selenium grid which can be access using
http://localhost:4444
.-
To run the tests on Selenium Grid using
TestNG
:Right click on
test-suite\testng-seleniumgrid-theinternet.xml
and selectRun test-suite\testng-seleniumgrid-theinternet.xml
-
To run the tests on Selenium Grid using
Maven
:mvn clean install -Dsuite-xml=test-suite\testng-seleniumgrid-theinternet.xml
-
-
Stopping the Selenium Grid:
docker-compose -f docker-compose-v3-seleniumgrid.yml down
-
Start the
Juice -Shop
website using following command:docker-compose -f docker-compose-v3-juiceshop.yml up -d
-
Start
Selenium Grid
using following command:docker-compose -f docker-compose-v3-seleniumgrid.yml up -d
-
Run the tests using
TestNG
:Right click on
test-suite\testng.xml
and selectRun test-suite\testng.xml
-
Run the tests using
Maven
in headless mode:mvn clean install -Dheadless=true
-
Stopping the
Juice-Shop
website andSelenium Grid
:docker-compose -f docker-compose-v3-juiceshop.yml down --remove-orphan
-
There are 2 ways to run the tests, those are as follows:
- Right-Click on the
test-suite\testng-lambdatestecommerce.xml
and selectRun ...\test-suite\testng-lambdatestecommerce.xml
-
To run the tests in headless mode update the value for
headless
property variable totrue
mvn clean install -Dsuite-xml=test-suite\testng-lambdatestecommerce.xml -Dheadless=true
-
To run the tests without headless mode(to see the test running in browser) update the value for headless property variable to
false
mvn clean install -Dsuite-xml=test-suite\testng-lambdatestecommerce.xml -Dheadless=false
- Right-Click on the
- Selenium 4 WebDriver Hierarchy: A Detailed Explanation
- Understanding CSS Selectors in Selenium
- End to End testing using Selenium WebDriver and Java
- Writing Selenium Web Automation tests in Fluent way!
- How To Automate Shadow DOM In Selenium WebDriver?
- How to setup GitHub Actions for Java with Maven project?
- How to Automate ServiceNOw with Selenium
- Cross browser testing in Selenium WebDriver
- Discuss your queries by writing to me @
[email protected]
OR ping me on any of the social media sites using the below link:
- Contact me for Paid trainings related to Test Automation and Software Testing,
mail me @
[email protected]
or ping me on LinkedIn