This project demonstrates the integration of Cucumber with Selenium for automated end-to-end testing in Java. It provides a framework for writing behavior-driven development (BDD) test scenarios that are executed using Selenium WebDriver.
The cucumber-with-selenium repository showcases how to leverage Cucumber for defining acceptance tests in a human-readable format (Gherkin) and executing them with Selenium WebDriver for browser automation. This approach enhances collaboration between developers, testers, and business stakeholders by ensuring that the tests accurately reflect the desired behavior of the application.
.feature files).This project uses Maven for dependency management. To set up the project:
git clone https://github.com/phambaophuc/cucumber-with-selenium.git
cd cucumber-with-selenium
msedgedriver.exe for your system from the official Microsoft Edge WebDriver releases.msedgedriver.exe in a directory that is included in your system's PATH environment variable, or specify its path directly in the code if needed (though not recommended for general use).mvn clean install
This project is designed to run automated tests against web applications. The tests are defined in .feature files and implemented in Java step definition classes.
To run all the defined Cucumber tests, you can execute the RunSteps class, which is configured as a JUnit test runner.
src/test/java directory.RunSteps.java file.RunSteps.java and selecting 'Run' or 'Debug'.Alternatively, you can run the tests from the command line using Maven:
mvn test
Login Functionality:
src/test/resources/features/login.featuresrc/test/java/stepdefinitions/LoginSteps.javahttp://localhost:4000/login.Product Management:
http://localhost:3001/#/booking/product/addProduct).CreateProductSteps.javacreate-product.featurehttp://localhost:3001/#/booking/product).EditProductSteps.javaedit-product.featurehttp://localhost:3001/#/account/role).DeleteProductSteps.javadelete-product.featurehttp://localhost:4000/).DetailProductSteps.javadetail-product.featurehttp://localhost:4000/).OrderProductSteps.javaorder-product.featureUser Registration:
src/test/resources/features/register.featuresrc/test/java/stepdefinitions/RegisterSteps.javahttp://localhost:4000/register.Note: The tests assume the target web applications are running locally on the specified ports (http://localhost:3001 and http://localhost:4000).
cucumber-with-selenium/
├── .idea/
│ ├── encodings.xml
│ ├── misc.xml
│ ├── ui-designer.xml
│ └── vcs.xml
├── src/
│ ├── main/java/org/example/
│ │ └── Main.java
│ └── test/java/
│ ├── RunSteps.java
│ └── stepdefinitions/
│ ├── CreateProductSteps.java
│ ├── DeleteProductSteps.java
│ ├── DetailProductSteps.java
│ ├── EditProductSteps.java
│ ├── LoginSteps.java
│ ├── OrderProductSteps.java
│ └── RegisterSteps.java
│ └── test/resources/features/
│ ├── create-product.feature
│ ├── delete-product.feature
│ ├── detail-product.feature
│ ├── edit-product.feature
│ ├── login.feature
│ ├── order-product.feature
│ └── register.feature
├── pom.xml
└── README.md
.idea/: IntelliJ IDEA project configuration files.src/main/java/: Contains the main application code (in this case, a simple Main class).src/test/java/: Contains the test code.RunSteps.java: The Cucumber test runner class.stepdefinitions/: Contains the Java classes implementing the step definitions for the Gherkin scenarios.src/test/resources/features/: Contains the Gherkin feature files (.feature).pom.xml: The Maven project configuration file, defining dependencies and build settings.README.md: This file.This project is not currently under any specified license. Please refer to the repository URL for more information.
© 2024 phambaophuc/cucumber-with-selenium
Author: phambaophuc
Feel free to star ⭐, fork 🍴, and open issues ❗ for any improvements or bug reports.