Repository name in Docker Hub: williamyeh/behave
This repository contains Dockerized Python tools for SBE/BDD, published to the public Docker Hub via automated build mechanism.
This docker image contains the following software stack:
-
Base image: Debian Stretch + Python 3.
-
Behave: behavior-driven development, Python style.
-
Selenium WebDriver: a suite of tools to automate web browsers across many platforms.
-
ChromeDriver: a standalone server which implements WebDriver's wire protocol for Chromium.
-
Selenium wrapper for Python:
- Elementium: jQuery-style syntactic sugar for Selenium.
- Capybara: a port of Capybara from Ruby.
-
Other useful Python testing libraries for convenience:
- Mockito: a spying framework ported from Java.
- PyShould: "Should"-style asserts based on PyHamcrest.
Given a features
sub-directory as follows:
.
└── features
├── environment.py
├── requirements.txt
├── xxx.feature
├── yyy.feature
└── steps
├── xxx_step.py
└── yyy_step.py
When I invoke the program as follows:
$ docker run -it --rm -v "$(pwd):/behave:ro" williamyeh/behave
Then I can see the output as follows:
Feature: ...
[...]
1 feature passed, 0 failed, 0 skipped
7 scenarios passed, 0 failed, 0 skipped
21 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m11.532s
Note: requirements.txt
in features
directory.
This is the default mode. All are done within the Docker container.
To run with the desktop's browser, please follow the steps.
+---------------------------------------------------------+
| |
| host |
| +----------------+ |
| | Docker | |
| | | |
| | | |
| | | |
| | | |
| | container | Chrome |
| | | | ChromeDriver browser |
| +----------------+ | | | |
| | | | | |
| +---------------+ +----------+ |
| /wd/hub:9515 |
| |
+---------------------------------------------------------+
-
Install Chrome.
-
Install ChromeDriver. Mac users can install it as follows:
$ brew install chromedriver
Windows users can install it as follows:
> choco install chromedriver
Configure features/environment.py
as follows:
# import useful functions
from environment_common import init_selenium_chrome_driver
from environment_common import use_headless_mode
from environment_common import set_remote_chrome_addr
...
# invoke them, if necessary
use_headless_mode(False)
...
# customize hooks, if necessary
def before_all(context):
...
-
Start the ChromeDriver with base URL path
/wd/hub
and default port9515
:$ chromedriver --url-base=/wd/hub
-
Now you're ready to run
williamyeh/behave
!
If you encounter the error WebDriverException: Message: Host header or origin header is specified and is not localhost.
try to add the container's IP address into the whitelist as follows:
$ chromedriver --url-base=/wd/hub --whitelisted-ips="xxx.xxx.xxx.xxx"
- Detailed document.
- Firefox?
- Flow with Jenkins.
Behave
Selenium
Elementium
Capybara
Author: William Yeh [email protected]
Licensed under the Apache License V2.0. See the LICENSE file for details.