This project is a Selenium and Cucumber-based test automation framework for the OWASP Juice Shop application. It includes integration with OWASP ZAP for security testing.
cucumber-selenium-gradle/
|-- build.gradle
|-- src/
|-- main/
| |-- java/
| |-- pages/
| |-- JuiceShopPage.java
|-- test/
|-- java/
|-- steps/
|-- JuiceShopLoginSteps.java
|-- Hooks.java
|-- runners/
|-- TestRunner.java
|-- features/
|-- juice_shop_login.feature
|-- resources/
|-- environment.properties
|-- README.md
- Java JDK 8 or higher
- Gradle
- Chrome Browser
- ChromeDriver
- OWASP ZAP (Zed Attack Proxy)
-
Clone the repository:
git clone <repository-url> cd cucumber-selenium-gradle
-
Install dependencies:
Gradle will automatically download the required dependencies.
-
Configure environment properties:
Edit the
environment.propertiesfile located insrc/test/resourcesto specify your environment configurations.# environment.properties env=prod # Production environment prod.url=https://demo.owasp-juice.shop prod.username=demo@example.com prod.password=password # Development environment dev.url=http://localhost:3000 dev.username=dev@example.com dev.password=devpassword
To run the tests without OWASP ZAP:
./gradlew test -Dscan=falseTo run the tests with OWASP ZAP passive scanning:
./gradlew test -Dscan=passiveTo run the tests with OWASP ZAP active scanning:
./gradlew test -Dscan=activeBy default, the tests run against the production environment specified in environment.properties. To run the tests in a different environment (e.g., development):
./gradlew test -Dscan=passive -Denv=devThe build configuration file for Gradle, including dependencies for Selenium, Cucumber, WebDriverManager, and OWASP ZAP.
This class contains methods to interact with the Juice Shop application, such as opening the app, closing the welcome popup, logging in, and verifying the login status.
This class contains the Cucumber step definitions for the login feature.
This class sets up and tears down the WebDriver instance before and after each test. It also integrates OWASP ZAP for security testing.
This class is the Cucumber test runner.
The Cucumber feature file that contains the login scenario.
This file contains environment-specific configurations such as URLs, usernames, and passwords.
OWASP ZAP scan reports will be generated in the project root directory:
passive-scan-report.htmlfor passive scansactive-scan-report.htmlfor active scans
- Environment Configuration: Use the
environment.propertiesfile to manage different environments. - Page Object Model (POM): Organize web elements and actions in page classes for maintainability.
- Reusable Methods: Create reusable methods in page classes for common actions.
- Separation of Concerns: Keep the test logic in step definition classes and the application-specific interactions in page classes.
- Security Testing Integration: Use OWASP ZAP for passive and active security scanning.
Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.
This project is licensed under the MIT License.