walnutjs

2.0.3 • Public • Published

walnutjs

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!

https://nodei.co/npm/walnutjs.png?downloads=true&downloadRank=true&stars=true

CircleCI Npm version License contributions welcome

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.

Getting Started

These instructions will give you a sample feature file to show you how easy is to make your own tests

Prerequisites

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:

Setup the project

  1. 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
  2. Setting up a walnut-config.js file inside rootFolder based on this file

  3. 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.

  4. 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}']" }
                ]
            }
        ]
    }
  5. 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'
  6. Before execution check that selenium webserver was started correctly. For this sample we will use webdriver-manager

    webdriver-manager start
    ...
    10:15:57.230 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
  7. Define a single start script in your package.json:

     "scripts"{
        "start": "walnut",
      }
  8. Execute your script

    npm start

    You can also run using $(npm bin)/walnut on your terminal

More details

Review this project boilerplate to get more insights and this documentation to see more details.

Running the tests

Just run the following command inside the root folder:

  • test: npm run test
  • coverage: npm run coverage

Built With

  • 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.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License.

Dependencies (15)

Dev Dependencies (5)

Package Sidebar

Install

npm i walnutjs

Weekly Downloads

43

Version

2.0.3

License

MIT

Unpacked Size

134 kB

Total Files

71

Last publish

Collaborators

  • sednemm