This project adds selenium grid extension to the official docker-selenium images to enable remote Sikuli operations and files transfer with grid nodes. Extensions are based on great project Selenium Grid Extensions.
Images included:
- bravo/grid/hub: Image for running a Selenium Grid Hub
- bravo/grid/node-chrome: Selenium node with Chrome installed, needs to be connected to a Selenium Grid Hub
- bravo/grid/node-firefox: Selenium node with Firefox installed, needs to be connected to a Selenium Grid Hub
- bravo/grid/node-chrome-debug: Selenium node with Chrome installed and runs a VNC server, needs to be connected to a Selenium Grid Hub
- bravo/grid/node-firefox-debug: Selenium node with Firefox installed and runs a VNC server, needs to be connected to a Selenium Grid Hub
build.sh
bravogridctl.sh start
To stop running container use command:
bravogridctl.sh start
Extension proxy objects are instantiated through io.sterodium.rmi.protocol.client.RemoteNavigator as follows:
String urlHub = "http://192.168.99.100:4444/wd/hub"
RemoteWebDriver driver = new RemoteWebDriver(urlHub, caps);
URL urlHubParsed = new URL(urlHub);
String driverSessionId = driver.getSessionId().toString();
String EXTENSION_PATH_FMT = "/grid/admin/HubRequestsProxyingServlet/session/%s/BravoExtensionServlet"
String extensionPath = String.format(EXTENSION_PATH_FMT, driverSessionId);
RemoteNavigator = new RemoteNavigator(urlHubParsed.getHost(), urlHubParsed.getPort(), extensionPath);
SikuliScreen screen = navigator.createProxy(SikuliScreen.class, "screen");
FileTransfer files = navigator.createProxy(FileTransfer.class, "files");
To remotelly control sikuli, first add base64 encoded png image content as sikuli target with choosen name and then search this target via sikuli using same name.
String b64PNG = DatatypeConverter.printBase64Binary(Files.readAllBytes(pngPath));
Strign myTargetName = "SomeUniqueName";
screen.addTarget(myTargetName, b64PNG);
ScreenRegion target = screen.find(myTargetName);
target.click()
To upload file call method saveFile on FileTransfer object, eg:
String remotePath = files.saveFile(".html", "/path/to/test.hml");
driver.get("file://" + remotePath);
Install RealVNC or any other VNC client, and connect to 127.0.0.1:6000 (Chrome) or 127.0.0.1:7000 (Firefox)