aahmadts / jwebrobot

WebRobot for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JWebRobot

Maven Central Build Status codecov.io Gitter Docker Hub

Latest release can be downloaded directly from here.

Short Description

JWebRobot is the reference implementation of web automation markup language. Currently the implementation is based on the draft-02 schema.

References

Refer to the changelog for recent notable changes and modifications.

Refer to the waml-schema for schema sources.

Options

Options may be passed to the JWebRobot using single hyphen notation:

java -jar <path to jar> -<argument name> [<argument value> ...]
Name Type Description Default Example
scenarioPath optional Scenario path may be a directory or a single scenario file. ./ ../path/to/my/scenario
scenarioPaths optional Scenario paths may be a directory, a single scenario file or a set of both. ../path/to/my/scenario ../path/to/my/another/scenario
scenarioPattern optional If set, only non fragment scenarios with a name matching the pattern are executed. - '^desired-scenario$'
context optional Context is a multi value argument that populates the context utilized during expression evaluation. - baseUrl=http://www.wikipedia.com language=en
timeout optional Timeout waiting for conditions to be fulfilled in seconds. Globally overrides timeout settings defined in the scenarios. - 5
screenshotPath optional Path to the directory where created screenshots must be saved. ./ ./
screenshotType optional Defines the way screenshots must be taken - fullscreen vs. viewport. VIEW_PORT FULLSCREEN
screenshotFormat optional Defines the screenshot format. png gif
takeScreenshots optional Defines when to take screenshots: NEVER, ON_FAILURE, ON_EVERY_STEP ON_FAILURE ./
browser optional A browser can be selected by passing this option when running JWebRobot. Please consider that some browsers require additional configuration parameters. WAML scenarios are executed with Mozilla Firefox per default. Firefox must be installed on the same machine. E.g.: Chrome does not provide embedded webdriver so that it has to be downloaded manually. The path to the downloaded executable has to be forwarded via the system property webdriver.chrome.driver. Of course, Chrome must be present on the same machine. firefox chrome
reportPath optional Path to which the report is written to. ./report.yaml ./myreport.yaml
maximizeWindow optional Toggles window maximization before scenario execution. false true
mode optional Selects the execution mode. Currently legacy non-interactive and interactive mode with the possibility to pause/step-wise execution are supported. non-interactive interactive

Expressions

Expression are evaluated by the awesome templating engine freemarker. The expression syntax and result may be tested using online template-tester.

Expression Context Result Description
${foo} foo="bar" bar Renders the context parameter value
${(foo=="bar")?c} foo="bar" true Tests context parameter foo for having the value "bar" and renders the boolean value.

Reserved Namespace

The lodash (_) name space is reserved for utility functions.

Mock

Mock utility provides an easy way to create test data required during test execution.

Find some examples below:

Expression Description
${ _.mock.person().fullName() } Creates a sane person full name
${ _.mock.person().email() } Creates a valid email address
${ _.mock.person().telephoneNumber() } Creates a valid phone number
${ _.mock.company().name() } Creates a sane company name

Behind the scenes a powerful test data framework jfairy is doing the job. More usage examples may be found there.

Store Criterion & Element Reference

While using steps containing filter criteria (e.g. ensure, click, enter, select, move) the reference to the filtered element may be stored using the store criterion, e.g.:

ensure:
    selector: input[type=text]
    store: userEmailInput
store:
    userEmailInputEnabled: ${userEmailInput.isEnabled()?c}

Note that the element reference currently exports the underlying selenium webelement api. The direct access is an experimental feature and may be subject to change in the future releases.

Source Build

An executable JAR can be created by executing the package Maven goal:

mvn package

Run JWebRobot as Docker Container

For easier bootstrapping, the JWebRobot is available as Docker image on Docker Hub. The automatewebsite/jwebrobot-chrome image is based on the official selenium/node-chrome image.

Usage

It is assumed that you already have a scenario file which is placed in a certain <scenario folder>. Thus, jwebrobot-chrome container can be executed as following:

docker run -v <scenario folder>:/var/jwebrobot automatewebsite/jwebrobot-chrome

In complex setup, you may want to pass additional parameters to the container, e.g.:

docker run -v <scenario folder>:/var/jwebrobot \
    -e JWEBROBOT_OPTS="-timeout 10 -takeScreenshots ON_EVERY_STEP" \
    -e SCREEN_WIDTH=800 \
    -e SCREEN_HEIGHT=600 \
    -e JAVA_OPTS="-Dhttp.proxyHost=proxy.example.com -Dhttp.proxyPort=1234" \
    automatewebsite/jwebrobot-chrome

The execution report will be stored in <scenario folder>/report.

About

WebRobot for Java

License:MIT License


Languages

Language:Java 98.9%Language:Shell 0.8%Language:HTML 0.3%