- This repo has example codes with Selenium 4 features.
- Websites used for testing are: 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?
- Selenium 4 WebDriver Hierarchy: A Detailed Explanation
- Selenium Manager in Selenium 4.11.0: New Features and Improvements
- Different Types of Locators in Selenium WebDriver
- How to Locate Elements Using CSS Selectors in Selenium
- How to Use @FindBy Annotation in Selenium Java
- 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
- How to Handle ElementClickInterceptedException in Selenium Java
- How To Download & Upload Files Using Selenium With Java
- ExpectedConditions In Selenium: Types And Examples
- How to Handle StaleElementReferenceException in Selenium
- How To Take Full Page Screenshots In Selenium WebDriver
- 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
- Discuss your queries by writing to me @
mohammadfaisalkhatri@gmail.com
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 @
mohammadfaisalkhatri@gmail.com
or ping me on LinkedIn
There are cases when proxies may be required to run the tests, this may happen when the software teams are working in isolation at different places. Residential proxies help in keeping the user’s information safe and help in hiding the real location of the user It acts as a middleman between the device and the internet and keep the users safe from being tracked.
NodeMaven provides high quality proxies with industry-first filtering, super sticky sessions and best customer support. Try out NodeMaven now(Use F86 at checkout to get extra 2GB of proxy)