Skip to content

neueda/selenium-grid-extensions

 
 

Repository files navigation

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.

More to come...

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.

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:

  • Get Hub extensions proxy jar file and put it together with selenium-server-standalone-x.y.z.jar
  • Modify hubConfig.json (servlets and capability matcher property)
...
 "servlets": [
    "io.sterodium.extensions.hub.proxy.HubRequestsProxyingServlet"
  ],
...
  "capabilityMatcher": "io.sterodium.extensions.capability.CustomCapabilityMatcher"
...

Launch grid with

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

Selenium node:

  • Get All node extensions jar file and put it together with with selenium-server-standalone-x.y.z.jar
  • Modify nodeConfig.json (capabilities and servlet properties)
...
"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-2.48.2.jar:all-node-extensions-x.y.z.jar" org.openqa.grid.selenium.GridLauncher -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);

Build

$ git clone [email protected]:sterodium/selenium-grid-extensions.git
$ cd selenium-grid-extensions/
$ mvn install