All Projects → labs42io → web-automation

labs42io / web-automation

Licence: MIT License
BDD tests with Cucumber, WebdriverIO and Docker Selenium

Programming Languages

typescript
32286 projects
Gherkin
971 projects
shell
77523 projects
javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to web-automation

Webdriverio
Next-gen browser and mobile automation test framework for Node.js
Stars: ✭ 7,214 (+6228.07%)
Mutual labels:  cucumber, webdriverio
demo-webdriverio-cucumber
E2E Tests with WebdriverIO and Cucumber
Stars: ✭ 28 (-75.44%)
Mutual labels:  cucumber, webdriverio
karate-runner
VSCode Extension for Karate
Stars: ✭ 23 (-79.82%)
Mutual labels:  cucumber, automation-testing
CucumberSwift
A lightweight swift Cucumber implementation
Stars: ✭ 40 (-64.91%)
Mutual labels:  cucumber
pactum
REST API Testing Tool for all levels in a Test Pyramid
Stars: ✭ 190 (+66.67%)
Mutual labels:  cucumber
behave2cucumber
Behave to Cucumber converter
Stars: ✭ 21 (-81.58%)
Mutual labels:  cucumber
flutter gherkin
A Gherkin parsers and runner for Dart and Flutter which is very similar to cucumber
Stars: ✭ 160 (+40.35%)
Mutual labels:  cucumber
gavel-spec
Behavior specification for Gavel, validator of HTTP transactions
Stars: ✭ 105 (-7.89%)
Mutual labels:  cucumber
webdriverio-testing-library
🕷️ Simple and complete WebdriverIO DOM testing utilities that encourage good testing practices.
Stars: ✭ 13 (-88.6%)
Mutual labels:  webdriverio
wdi5
cross-platform test framework for UI5 web-apps. wdi5 = Webdriver.IO + UI5 Test API
Stars: ✭ 45 (-60.53%)
Mutual labels:  webdriverio
Android-Cucumber-BDD-Sample
A sample project that has most of the tests and code written in a Behaviour Driven Development style, using the Cucumber framework.
Stars: ✭ 29 (-74.56%)
Mutual labels:  cucumber
nightwatch-boilerplate
boilerplate for nightwatch.js with selenium
Stars: ✭ 16 (-85.96%)
Mutual labels:  docker-selenium
gulp-webdriver
gulp-webdriver is a gulp plugin to run selenium tests with the WebdriverIO testrunner
Stars: ✭ 77 (-32.46%)
Mutual labels:  webdriverio
cucumber-react
React components for Cucumber
Stars: ✭ 15 (-86.84%)
Mutual labels:  cucumber
cucumber
Cucumber testing framework for Rust. Fully native, no external test runners or dependencies.
Stars: ✭ 322 (+182.46%)
Mutual labels:  cucumber
cucumber-steps
🥒 Quick start for testing with Cucumber.js
Stars: ✭ 15 (-86.84%)
Mutual labels:  cucumber
spring-boot-microservice-best-practices
Best practices and integrations available for Spring Boot based Microservice in a single repository.
Stars: ✭ 139 (+21.93%)
Mutual labels:  cucumber
sonar-gherkin-plugin
SonarQube Cucumber Gherkin Analyzer
Stars: ✭ 33 (-71.05%)
Mutual labels:  cucumber
knapsack pro-ruby
Knapsack Pro gem splits tests across parallel CI nodes and makes sure that tests will run in optimal time on each node.
Stars: ✭ 101 (-11.4%)
Mutual labels:  cucumber
LocalSupport
A directory of local support services and volunteer opportunities
Stars: ✭ 60 (-47.37%)
Mutual labels:  cucumber

Web Automation Framework

CircleCI CI Build Status

Boilerplate project to write BDD tests with Cucumber and execute with docker selenium. Tests are written in an ordinary language that bridges the gap between business and technical people. The docker selenium simplifies the setup and avoids any local installation of browser specific dependencies.

Features

  • Simple setup, no need for local preinstalled Selenium Grid and browser drivers
  • Test with Chrome and Firefox with zero configuration
  • Integrated with WebdriverIO
  • BDD tests with Cucumber and over 150 predefined steps
  • Implement custom steps with TypeScript
  • Support for debugging tests
  • Possibility to visually see the execution in browser with VNC
  • Detailed report generation (example)
  • Integration with CI tools

Requirements

  • To run Firefox and Chrome browsers with docker selenium you need:

    • docker
    • docker-compose
  • Tests are executed with Node.js, requires:

    • Node.js version 10 or higher
    • npm version 6 or higher

Quick start

  1. Install dependencies required to run the tests:
npm install
  1. Start docker selenium containers with docker-compose:
# starts the selenium hub and browser nodes in docker containers
npm run selenium
  1. Run the tests and view the report:
# run tests and open the report
npm run test

To stop all the docker containers from step 2:

npm run selenium:stop

Note that selenium containers can be started once and then used across multiple sessions of running and debugging tests.

Test examples

File
./src/features/google.search.feature An example of testing the Google search
./src/features/sample.snippets.feature Samples of using the existing test snippets. Credits Christian Bromann

Adding tests

Tests are written using Gherkin syntax in a fashion that can be used as feature documentation:

# This is a single line comment
Feature: Performing a Google Search

    As a user on the Google search page
    I want to search for Selenium-Webdriver
    Because I want to learn more about it

    Background:
        Given I open the url "https://google.com"

    Scenario: Searching for Selenium Webdriver
        When I set "Selenium Webdriver" to the inputfield "[name=q]"
        And  I press "Enter"
        Then I expect that element "#search" becomes displayed

All tests should be located in ./src/features/* directory with extension .feature (configured in ./config/tests.config.ts).
For a list of predefined and supported steps see files:

  • ./src/steps/given.ts
  • ./src/steps/when.ts
  • ./src/steps/then.ts.

The steps are inspired from cucumber-boilerplate repository.

Implementing custom steps

There are over 150 predefined steps, but in case you need an extra step you can add it in one of the ./src/steps file.
The snippets are defined using regular expressions. It allows to implement powerful and complex sentences. Everything that's within "([^"]*)?" gets captured and appended to the callback.
To access browser functionality, reference the global variable browser which is a WebdriverIO browser instance. See the documentation for a list of supported methods.
Assertions are written using chai.

Browser specific tests

To run a test against a specific browser use predefined tags:

Feature: Performing a Google Search

    ...

    # This scenario will run only in Chrome browser
    @OnlyChrome
    Scenario: Searching in chrome browser
    ...

    # This scenario will run only in Firefox browser
    @OnlyFirefox
    Scenario: Searching in Firefox browser
    ...

Pending tests

To skip a test, use the @Pending tag:

Feature: Performing a Google Search

    ...

    # This scenario will be skipped
    @Pending
    Scenario: Searching for WebdriverIO
    ...

Verbose tests

Currently, a screenshot is attached only for a failing test. In case you want screenshots for a test regardless of its completion status, use the @Verbose tag:

Feature: Performing a Google Search

    ...

    # A screenshot and additional test details will be attached to the report
    @Verbose
    Scenario: Searching for WebdriverIO
    ...

Hooks

Hooks are blocks of code that can run at various points in the Cucumber execution cycle. It is possible to write conditional hooks.
See examples of scenario hooks in ./src/steps/hooks.ts. For a more advanced usage, configure hooks in ./config/hooks.config.ts.

You can customize existing hooks or implement your own. See the WebdriverIO documentation about hooks.

Configurations

Environment variables

The configurable options are set in the .env file.

Variable Usage
SELENIUM_VERSION Configure the version of selenium hub and nodes. Change this version if you want to run tests against a specific browser version. See the list of available selenium releases and browser versions.
SCREEN_WIDTH SCREEN_HEIGHT Configure browser window size.

WebdriverIO options

WebdriverIO specific options are all in ./config directory.
For example, to configure a default url change the baseUrl option in ./config/index.ts:

export const config = {
  runner: 'local',
  baseUrl: 'https://webdriver.io',
  ...

Debugging tests

There is a ./.vscode/launch.json file that has a debugger configuration for Visual Studio Code, but you can enable debugging in any other editor that supports integration with Node.js debugger.

To debug a single feature file:

  • Prerequisites: selenium containers are running (npm run selenium)

  • The .feature file to test is active in VS Code

  • From VS Code Run and Debug menu select the Debug current test option

The test will start and run only the current file. Once started you can navigate to any .ts file and place a breakpoint.

To debug all files follow the same steps but use the Debug all tests option.

VNC support

In some cases, you might need to visually see the execution in the browser. That is possible thanks to docker selenium debug images that have XVFB and VNC server installed. Note that debug images are slower and are intended only for development mode.

Prerequisites

Download on your machine the VNC viewer.

Selenium Debug containers

If you already have docker selenium containers running, stop them:

npm run selenium:stop

Start selenium debug containers that enable the VNC support:

# starts the selenium containers with VNC support
npm run selenium:vnc

VNC connection options

Browser Connection options
Chrome 127.0.0.1:5900
Firefox 127.0.0.1:5901

Now you can connect and enter the remote session.

Running tests

Tests by default run in headless mode so that a browser window is not visually created. To run the tests with enabled browser window:

# runs the tests without headless option
npm run test:vnc

Note that even if you started selenium with VNC support, you need to run the test:vnc command to see the browsers visually.

Debugging with VNC support is also possible. If you're using Visual Studio Code there are VNC Debug current test and VNC Debug all tests debugging configurations that work similar to configurations described in Debugging tests section.

To stop the debug containers use the same command:

npm run selenium:stop

CI integration

Integration with a CI tool is easy if it supports docker and docker-compose tools.
There is a Dockerfile to build an image that bundles Node.js, npm and tests. The docker-compose.ci.yml configures all the dependencies required to run the tests in containers:

docker-compose -f docker-compose.ci.yml up --abort-on-container-exit --exit-code-from node

There are npm scripts to avoid running long commands:

# only builds the Dockerfile image
npm run ci:build

# runs the tests in containers
npm run ci
CI Status Config Artifacts
CircleCI CircleCI ./.circleci/default.yml Report uploaded as artifacts that can be viewed directly in the browser.
Github Actions CI ./.github/workflows/main.yml Report files available as a downloadable zip in artifacts.
TravisCI Build Status ./.travis.yml You need to configure Amazon S3 account to enable artifacts.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].