Skip to content
This repository has been archived by the owner on Aug 13, 2018. It is now read-only.

andrealbinop/fitnesse-selenium-slim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fitnesse-selenium-slim Build Status Coverage Status javadoc Maven  Central

FitNesse Selenium fixture in slim format. Resembles Xebium, but it's even more similar to Selenium IDE Firefox Plugin. Also gets inspiration from hsac-fitnesse-fixtures but doesn't try to "simplify" Selenium IDE development flow. This project is licensed under MIT.

Getting started

Since the plugin tests itself with FitNesse, take a look at this FitNesseRoot test. Furthermore, detailed information about the available fixture commands can be found here.

Installation

  • This module and selenium dependencies must be in FitNesse classpath. You can download the jars from here or with maven (see below).
  • The WebDriver which the fixture will be used to connect also must be on FitNesse classpath.
<dependency>
  <groupId>com.github.andreptb</groupId>
  <artifactId>fitnesse-selenium-slim</artifactId>
  <version>1.0.3</version>
</dependency>

Testing and Building

BROWSER=firefox mvn test
  • To start FitNesse server and navigate through samples:
mvn exec:java -Dexec.mainClass=fitnesseMain.FitNesseMain -Dexec.args="-d fitnesse" -DBROWSER=firefox
  • To build this plugin and add to maven local repository:
mvn install -Dgpg.skip

Advanced

The following sections details some advanced features provided by this plugin.

Aborting test on first failure

In some use cases, such as when you select an option that changes form fields in the page, if selenium can't select this option it wouldn't make sense to go on with the test. Since subsequent actions will respect wait behavior, this test would waste a lot of time executing actions even though it will fail for sure.

To address this, the action stop test on first failure can be enabled. This will abort all actions that come after the action that failed. Note that this flag is kept across tests and suites, so if this functionality is needed, it's wise to configure it properly in each suite or test SetUp.

Some situations will cause the test to be aborted even if stop test on first failure is false, such as using an action that requires the browser to be started (with start browser.

Screenshots

This plugin provides a screenshot feature, showing the screenshot preview (and link) similar to hsac-fitnesse-plugin. Screenshots can be triggered when:

  • An assertion fails, mostly when an element can't be found in the page or it's contents is somehow unexpected.
  • Manually, by using along with screenshot action along with show prefix, as demonstrated below:
| selenium |
|
| show | screenshot |

Known limitations:

Wait behavior

Every actions that involves searching for elements within the page will respect the specified timeout configuration before failing. You can change the timeout configuration with the following:

| selenium |
| note | changes timeout configuration for 5 seconds (default is 20) |
| set wait timeout | 5 |

Important:

  • If stop test on first failure is disabled, present action will return false if timeout is reached and no element was found with the given selector.
  • Wait behavior using FitNesse Slim action such as ensure, reject, check and check not will only work properly if selenium table is used.

Browser downloads

This plugin applies default configurations for Firefox and Chrome to download files without opening confirmation dialogs. If you wish to change the default download directory, you can use specific browser preferences, as described here (Firefox) and here (Chrome). Take a look at this test for a sample on how changing the default download directory can be achieved with Firefox and Chrome.

However, as mentioned here and here, accessing downloaded files proves to be a rather difficult task, especially when working with remote test providers such as Selenium Grid and SauceLabs. In these situations, another technique must be used. For example, if you're running selenium grid with Docker, you could create volumes to provide filesystem access between the container with the Selenium Node running the test and the container running FitNesse itself.

Dry run

Development with selenium can be slow, specially when tests contain many assertions. With FitNesse in the mix, currently there's no easy way to assert if code syntax and driver configuration is valid without having to effectively run the test.

This plugin offers a dry run mode, aiming to address just that. When enabled, the plugin runs your tests in a blank page and will fail only if:

  • The driver connection is incorrect or the browser is not available to receive selenium commands.
  • There are FitNesse or Selenium syntax errors.

As this practice implies, this feature intends to help with the following tasks:

  • Mitigate FitNesse and Selenium syntax problems in your test pages.
  • Verify the test effective order of execution and their resources (e.g. which setup page comes before the test itself)
  • Provide a quick sanity check as fast as possible.

Please note that the action start browser must be executed before dry run mode is enabled. Take a look at this test for an usage example.