walnutjs is a collection of generic steps for interact with web-applications.
You can easily simulate user interactions using a business-readable way. You only need to write some feature files using the Gherkin syntax and plan your tests with BDD (Behavior Driven Development) pattern.
Enjoy It!
Usage: walnut [options]
Walnut Framework - Automated BDD Tests for Web Applications
Options:
-V, --version output the version number
-c, --config <path> path to JSON config file
-t, --tags <tagName> name of tag to run (default: [])
-m, --execMethod <method> execution method [e.g runOnlyAPI]
-h, --help output usage information
Please see our wiki DOCs for more details.
These instructions will give you a sample feature file to show you how easy is to make your own tests
Before continue, check that you have completed the following requirements:
- java - Java runtime environment - tested on 1.8.0_211
- nodejs - A javascript runtime - tested on v10.16.0
- selenium webserver:
- webdriver-manager - A selenium server and browser driver manager.
- zalenium - A flexible and scalable selenium grid.
-
Start by creating a simple
nodejs
project and add walnutjs to it:mkdir my-app && cd my-app npm init -y npm i --save walnutjs
-
Setting up a
walnut-config.js
file inside rootFolder based on this file -
Create a folder structure like that:
> my-app > test > features sample.feature > step-defs custom-steps.js > locators locators.json > params params.json
You can create these folders above on your own, just be sure to indicate the correct paths inside
walnut-config.js
file. -
Add the folowing content to
locators.json
file:{ "containers":[ { "name": "GoogleHome", "locators":[ { "key": "SearchInput", "type": "name", "value": "q" }, { "key": "SearchButton", "type": "p:xpath", "value": "//input[@value='{0}']" } ] } ] }
-
Add the following content to
sample.feature
file:Feature: First test with walnutjs @simple_web Scenario: I want see the Google Page Given user navigates to 'http://www.google.com' When user fills 'GoogleHome-SearchInput' by replacing text with 'led zeppelin wikipedia' And user clicks on 'GoogleResult-SearchButton'
-
Before execution check that
selenium webserver
was started correctly. For this sample we will usewebdriver-manager
webdriver-manager start ... 10:15:57.230 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
-
Define a single start script in your
package.json
:"scripts": { "start": "walnut", }
-
Execute your script
npm start
You can also run using
$(npm bin)/walnut
on your terminal
Review this project boilerplate to get more insights and this documentation to see more details.
Just run the following command inside the root folder:
- test:
npm run test
- coverage:
npm run coverage
- nodejs - A JavaScript runtime
- cucumber - tool for running automated tests written in plain language
- selenium-webdriver - The official Webdriver Javascript bindings from the Selenium project.
- Marcio Mendes - Initial work - mmendesas
See also the list of contributors who participated in this project.
This project is licensed under the MIT License.