selenium4poc
                                
                                 selenium4poc copied to clipboard
                                
                                    selenium4poc copied to clipboard
                            
                            
                            
                        Learn Web Automation testing using Selenium Webdriver 4.
Don't forget to give a :star: to make the project popular.
:question: What is this Repository about?
- 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 Mavenas build tool andTestNGtesting framework to run the tests.
Talking more about the Scenarios Covered in this project:
- 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 owasp-juice-shop
Following is the Automation Test Strategy used for writing End-to-End Tests:
- 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 linkand 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 Basketlink.
- User will click on Your Basketlink 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 Youmessage order confirmation and delivery message.
- End-to-End tests for Juice Shop Website are running on 'http://localhost:3000' inside the container in GitHub actions.
- CI/CD Pipeline has been added using GitHub Actions. Checkout the blog How to setup GitHub Actions for Java with Maven project? for detailed explanation of how to set up pipeline using GitHub actions.
- Checkout the blog End to End testing using Selenium WebDriver and Java to get better understanding of how to write end-to-end tests.
End-to-End Tests for LambdaTest ECommerce Playground Website
Following is the automation test strategy used for writing end-to-end tests:
- 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.
- Checkout the blog Writing Selenium Web Automation tests in Fluent way! to get better understanding of how to write end-to-end tests using fluent pattern.
How to run the Tests?
Running Juice Shop Tests on your local machine:
- 
Start Juice-Shopwebsite locally, for doing this we will make use ofdocker-compose-v3-juiceshop.ymlwhich 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-Shopwebsite 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: 1. TestNG:- Right-Click on the test-suite\testng-juice-shop.xmland selectRun ...\test-suite\testng-juice-shop.xml
 2. Maven:- 
To run the tests in headless mode update the value for headlessproperty variable totruemvn 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 falsemvn 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
Running Selenium Grid on local and running tests using Selenium Grid
- 
Start the Selenium Grid in local using the docker-compose-v3-seleniumgrid.ymlfile.
- 
Run the following command: docker-compose -f docker-compose-v3-seleniumgrid.yml up -dThis 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.xmland 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
Running all the tests in one go:
- 
Start the Juice -Shopwebsite using following command:docker-compose -f docker-compose-v3-juiceshop.yml up -d
- 
Start Selenium Gridusing following command:docker-compose -f docker-compose-v3-seleniumgrid.yml up -d
- 
Run the tests using TestNG:Right click on test-suite\testng.xmland selectRun test-suite\testng.xml
- 
Run the tests using Mavenin headless mode:mvn clean install -Dheadless=true
- 
Stopping the Juice-Shopwebsite andSelenium Grid:docker-compose -f docker-compose-v3-juiceshop.yml down --remove-orphan
Running LambdaTest ECommerce Playground Tests on your local machine:
- 
There are 2 ways to run the tests, those are as follows: 1. TestNG:- Right-Click on the test-suite\testng-lambdatestecommerce.xmland selectRun ...\test-suite\testng-lambdatestecommerce.xml
 2. Maven:- 
To run the tests in headless mode update the value for headlessproperty variable totruemvn 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 falsemvn clean install -Dsuite-xml=test-suite\testng-lambdatestecommerce.xml -Dheadless=false
 
- Right-Click on the 
:question: Need Assistance?
- Discuss your queries by writing to me @ [email protected] OR you can ping me on the following social media sites:
- Twitter: mfaisal_khatri
- LinkedIn: Mohammad Faisal Khatri
- Contact me for 1:1 training related to Testing and Test Automation.