BDD Software Automation Testing using capybara ruby, and cucumber.
The framework follows the following approach:
-
Page Object Model (POM): The application's UI is divided into pages, and each page has its corresponding Page Object. This approach enhances code reusability and maintenance.
-
Cucumber Features and Scenarios: Test scenarios are written using Gherkin syntax in feature files. Each scenario corresponds to a Cucumber step definition.
-
Step Definitions: Step definitions are written using Capybara and Selenium to interact with the application and perform verifications.
-
Assertions and Verifications: Assertions and verifications are placed within step definitions to ensure the application behaves as expected.
-
Reporting: Cucumber generates human-readable HTML reports containing detailed test execution results.
- Ruby (Programming Language)
- Capybara (Web Automation)
- Selenium (WebDriver)
- Cucumber (Behavior-Driven Development)
- Bundler (Dependency Management)
- Ruby installed (version 3.2.2 is used for this repository)
- Chrome or Firefox browser installed
For more details how to install and setup
- Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Install RVM
curl -L get.rvm.io | bash -s stable
source ~/.bash_profile
Then run rvm requirements
and follow the instructions
- Install Ruby 3.2.2
rvm install 3.2.2
And make sure you have used the right version
rvm list
To use the version 3.2.2
rvm use 3.2.2
- Clone the project
git clone [email protected]:fathirwafda/automation-test-capybara.git
cd automation-test-capybara
- Copy .env file
cp env.sample .env
- Install bundler
gem install bundler
- Run bundle install
bundle install # or `bundle` for simpler command
- Copy env (This .env can be used for store your value to be more flexible)
cp env.sample .env
-
Go back to task_capybara_cucumber folder and run cucumber to make sure everything is installed
bundle exec cucumber -p web-desktop --tag @purchase-product
- JSON error when running
bundle
, update your XCode or runxcode-select --install
- Update the test data: Modify the test data, if required
- Run the tests using Cucumber:
bundle exec cucumber -p web-desktop --tag @purchase-product
- If you want to generate Cucumber reports:
bundle exec cucumber -p web-desktop --tag @purchase-product -f pretty -f html -o report.html -f json -o report.json
And open report.html by using a browser
Profile configuration : config/cucumber.yml
Platform | Command |
---|---|
Desktop | bundle exec cucumber -p web-desktop |
├── config
├── features
│ ├── helper
│ ├── pages
│ │
│ ├── scenarios
│ │ └── web
| |
│ ├── step_definitions
│ ├── screenshots
| ├── .env