Home

Awesome

Selenium Grid Extensions

Build Status Coverage Status Maven Central Gitter Chat

Set of Selenium Grid extensions for a better UI tests.

Full Documentation

See the Wiki for documentation, examples and other information.

Communication

What does this project do?

1) Allows you to run Sikuli tests remotely on the grid

Remove pain of testing complex UI components by hacking DOM. With this extension you are able to combine Selenium tests with Sikuli image recognition and run them on the grid.

Even more! Sikuli allows you to automate anything you see.

2) Download file from Selenium grid nodes

Downloading files in Selenium tests? Get them to your machine and check contents. Now it's easy.

3) Upload resources on Selenium grid nodes

You might have some file upload tests. Uploading files to remote environment is not a problem anymore.

Getting started

Extensions need to be installed on Selenium Grid. It is obligatory to have Extension proxy installed in the hub.

Binaries

Binaries and dependency information for Maven, Gradle and other build tools can be found at http://search.maven.org.

Docker

Look into project https://github.com/bravostudiodev/bravo-grid for docker images.

On client side for Maven:

<dependency>
    <groupId>io.sterodium</groupId>
    <artifactId>sikuli-extension-client</artifactId>
    <version>x.y.z</version>
</dependency>
<dependency>
    <groupId>io.sterodium</groupId>
    <artifactId>file-extension-client</artifactId>
    <version>x.y.z</version>
</dependency>

On grid side:

Selenium hub:

...
   "servlet": "io.sterodium.extensions.hub.proxy.HubRequestsProxyingServlet",
...
  "capabilityMatcher": "io.sterodium.extensions.capability.CustomCapabilityMatcher"
...

Launch grid with

java -cp "selenium-server-standalone-3.0.1.jar:extension-proxy-x.y.z.jar" org.openqa.grid.selenium.GridLauncherV3 -role hub -hubConfig hubConfig.json

Selenium node:

...
"capabilities": [
    {
      "extension.sikuliCapability": true
    }
  ],
"configuration": {
...
"servlets": "io.sterodium.extensions.node.SikuliExtensionServlet,io.sterodium.extensions.node.upload.FileUploadServlet,io.sterodium.extensions.node.download.FileDownloadServlet"
...
}

Launch node with

java -cp "selenium-server-standalone-3.0.1.jar:all-node-extensions-x.y.z.jar" org.openqa.grid.selenium.GridLauncherV3 -role node -nodeConfig nodeConfig.json

Hello world

Sikuli extension

Get session id from RemoteWebDriver

String sessionId = remoteWebDriver.getSessionId();

Create Sikuli client and upload images to selenium node:

SikuliExtensionClient client = new SikuliExtensionClient(host, port, sessionId);
client.uploadResourceBundle("my_images_folder");

Locate image on screen and click:

TargetFactory targetFactory = client.getTargetFactory();
ImageTarget imageTarget = targetFactory.createImageTarget("image.png");

DesktopScreenRegion desktop = client.getDesktop();
ScreenRegion screenRegion = desktop.find(imageTarget);

Mouse mouse = client.getMouse();
mouse.click(screenRegion.getCenter());

Refer to Sikuli docs for basic Sikuli API usage.

File extension

File upload to selenium node:

FileExtensionClient fileExtensionClient = new FileExtensionClient(host, port, sessionId);
String uploadPath = fileExtensionClient.upload(resourceBundlePath);

File download from selenium node:

FileExtensionClient fileExtensionClient = new FileExtensionClient(host, port, sessionId);
File fileFromNode = fileExtensionClient.download(pathToFile);

File deletion from selenium node: (which can be used as cleanup after upload/download activity performed on node)

FileExtensionClient fileExtensionClient = new FileExtensionClient(host, port, sessionId);
boolean isFiledeleted = fileExtensionClient.delete(pathToFile);

Build

$ git clone git@github.com:sterodium/selenium-grid-extensions.git
$ cd selenium-grid-extensions/
$ mvn install