Welcome to the repository for Selenium WebDriver Tests. This repository contains a set of automated tests written in Java using Selenium WebDriver and JUnit. The tests interact with a web application to ensure the functionality of various forms and dropdowns. This project has POM.XML configuration to produce detailed error reports with Surefire Reports and insert in DevOps methodology to be integrated in CD/CI pipeline with Jenkins and Docker.
Before running the tests, ensure you have the following installed:
- JDK 11 or higher: Required for compiling and running Java code.
- Maven or Gradle: To manage dependencies (choose one based on your preference).
- Selenium WebDriver: To perform browser automation.
- WebDriverManager: To automatically manage browser drivers.
- JUnit 4: Testing framework used to organize and execute tests.
- ChromeDriver: The WebDriver used for testing with Google Chrome.
You can use Maven or Gradle to manage the dependencies.
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies>
To run the testm follow the steps below:
1. Clone the repository to you local machine:
git clone https://bitbucket.org/your-username/your-repository.git
2. Install Mave or Gradle:
Maven Installation Guide - https://maven.apache.org/install.html
Gradle Installation Guide - https://gradle.org/install/
3. Install dependencies:
- with Maven:
mvn clean install
- with Gradle:
gradle build
To execute the testm you can use the following commands:
- with Maven:
mvn test
- with Gradle
gradle test
Alternatively, you can run the tests directly from your IDE (like IntelliJ or Eclipse) by selecting the test class and clicking Run.
setUp()
Purpose: Prepares the WebDriver and navigates to the application’s URL.
Actions:
Sets the WebDriver system property to use the jdk-http-client.
Uses WebDriverManager to set up the ChromeDriver.
Maximizes the browser window.
Waits until the URL contains the string search360.
Test1()
Purpose: Tests filling out a form.
Actions:
Fills in the form fields:
refInterna: test.refInterna
agente: test.agente
emailCliente: test.emailCliente
telefone: test.telefone
Takes a screenshot and saves it to C:\Screenshots\search_images2.png.
Test2()
Purpose: Tests selecting options in various dropdown menus.
Actions:
Selects the Linha de Atendimento dropdown (e.g., WhatsApp).
Selects the Categoria dropdown.
Selects the Sub-Categoria dropdown.
Selects the Motivo dropdown.
Selects the Estado dropdown.
Each dropdown selection is made after waiting for the corresponding option to become clickable.
tearDown()
Purpose: Cleans up after the test.
Actions:
Closes the browser window after each test.
- The tests automatically capture a screenshot after completing Test1(). The screenshot is saved to the local directory C:\CC360-selenium-java\src\test\java\screenshots
- You can modify this file path to save the screenshot to another location if needed.
-
WebDriver: The tests are configured to use Google Chrome. To use another browser (e.g., Firefox), modify the driver = new ChromeDrive (); line in the code.
-
WebDriverManager: Automatically manages the browser driver, ensuring compatibility between the Selenium version and the browser's driver.
-
JUnit: Tests are organized using JUnit 4, and execution order is based on method names (due to the @FixMethodOrder(MethodSorters.NAME_ASCENDING) annotation).
- If you would like to contribute to this project, follow these steps:
- Fork the repository.
- Create a new branch for your feature or fix.
- Make your changes and commit them.
- Push your changes to your fork.
- Submit a pull request.
We welcome contributions and are happy to review your changes!
- This project is licensed under the MIT License.