Disclaimer
This project was created for educational purposes. It is freely accessible to everyone. No liability is accepted for any damage resulting from its use.
Licenses used software packages
Description
This project is intended to provide an easy introduction to programming with Selenium WebDriver using Java. The project demonstrates the use of Selenium for automated testing of websites.
To make it easier to get started, the use of build tools has been left out. At this point there won't be any test report created. You can use the integrated Testing Explorer. I will demonstrate the use of the building tool Maven in a branch of this repository. (coming soon...)
I tried to use the Test Practices of Selenium and the encouraged use of Page object models.
If you have any questions feel free to contact me directly.
Further information:
Visual Studio Code Java Testing
Software Used
Microsoft Windows 11 v22H2
Firefox Browser v123.0.1
Google Chrome v122.0.6261.95
Microsoft Edge v122.0.2365.66
Java JDK v21.0.2
Selenium for Java v4.18.1 (WebDriver)
Microsoft Visual Studio Code V1.87.0
Extensions:
- Debugger for Java v0.56.2 of Microsoft
- Extension Pack for Java v0.25.15 of Microsoft
- IntelliCode v1.2.30 of Microsoft
- IntelliCode API Usage Examples v0.2.8 of Microsoft
- Language Support for JAVA(TM) by Red Hat v1.28.1 of Red Hat
- Maven for Java v0.44.0 of Microsoft
- Project Manager for Java v0.23.5 of Microsoft
- Test Runner for Java v0.40.1 of Microsoft
Installation Instructions (Windows 11)
Browsers
Download the browsers and install them with standard settings. Firefox you can install using the Microsoft store.
Java
- Download Java JDK
- Install
- Open Environment Variables
- In System Variables:
- New... --> Variable name: JAVA_HOME --> Variable value: C:\Program Files\Java\jdk-21
- Path --> Edit... --> New --> C:\Program Files\Java\jdk-21\bin
- Open Command Line --> java --version --> you should see the version installed
Selenium
- Download the Selenium WebDriver
- I extracted them to C:\Selenium\selenium-java-4.18.1
- If you use a different path you have to adjust adjust the Referenced Libraries to the path you extracted Selenium.
Visual Studio Code
- Open Microsoft Store in Windows
- Search for "visual studio code" (not the insiders version)
- Open it and install it
- After the installation is completed, start it
- On the left top side, press the button "Extensions"
- Search for the extensions (listed in the "Software Used" section above) and install them.
- After installation of all extensions, close visual studio and open it again.
- With "File --> Open Folder" you can open the folder where you downloaded the repository from github.
Hints
Finding XPath easy
An easy way to find and copy XPATH of web elements with Edge browser
- Open the website
- Press F12 to open "Inspect"
- Left-top-corner of "Inspect" press the button "Select ..."
- Now you can select an element on the website by clicking on it.
- The element will be highlighted in the "Inspect" as code
- Right-click the highlighted code "Copy --> Copy full Xpath"
- Enjoy your expath
Folder Structure and File Description
Folder contained in the workspace:
src
: the folder to maintain sources
src\page_objects
: the folder to maintain page objects
src\testcases
: the folder to maintain testcases
lib
: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the bin
folder by default.