This repository has been archived by the owner on Jun 30, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 334
Grid plugin: create a separate video for each test #77
Labels
Comments
Also read blog post http://qa-automation-notes.blogspot.de/2016/04/docker-selenium-and-bit-of-allure-how.html
@Override
public void beforeSession(final TestSession session) {
super.beforeSession(session);
processRecording(session, Command.START_RECORDING);
}
@Override
public void afterSession(final TestSession session) {
super.afterSession(session);
processRecording(session, Command.STOP_RECORDING);
}
private void processRecording(final TestSession session, final Command command) {
final String videoInfo = getCapability(session, "videoInfo");
if (!videoInfo.isEmpty()) {
final String url = "http://" + this.getRemoteHost().getHost() + ":" + this.getRemoteHost().getPort() +
"/extra/" + VideoRecordingServlet.class.getSimpleName() + "?command=" + command;
switch (command) {
case START_RECORDING:
sendRecordingRequest(url, videoInfo);
break;
case STOP_RECORDING:
sendRecordingRequest(url, "");
break;
}
}
}
private void sendRecordingRequest(final String url, final String entity) {
CloseableHttpResponse response = null;
try (final CloseableHttpClient client = HttpClientBuilder.create().build()) {
final HttpPost post = new HttpPost(url);
if (!entity.isEmpty()) {
post.setEntity(new StringEntity(entity, ContentType.APPLICATION_JSON));
}
response = client.execute(post);
LOGGER.info("Node response: " + response);
} catch (Exception ex) {
LOGGER.severe("Unable to send recording request to node: " + ex);
} finally {
HttpClientUtils.closeQuietly(response);
}
}
{
"capabilities": [
{
"browserName": "chrome",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
],
"configuration": {
"proxy": "com.blogspot.notes.automation.qa.grid.HubProxy",
"servlets": "com.blogspot.notes.automation.qa.grid.VideoRecordingServlet",
"maxSession": 1,
"port": 5555,
"register": true,
"registerCycle": 5000
}
}
private Capabilities getCapabilities() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName(getBrowser());
capabilities.setPlatform(getDefaultPlatform());
String videoInfo = getVideoRecordingInfo();
if (!videoInfo.isEmpty()) {
capabilities.setCapability("videoInfo", videoInfo);
}
return capabilities;
}
public String getVideoRecordingInfo() {
try {
VideoInfo videoInfo = new VideoInfo("/e2e/uploads", getVideoRecordingPath(), 18, 25);
return new ObjectMapper().writeValueAsString(videoInfo);
} catch (Exception ignored) {
return "";
}
} |
Closed via zalando/zalenium#17 thanks @diemol ! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Refs:
https://github.com/rossrowe/sauce-grid-plugin
https://github.com/freynaud/grid-plugin-tutorial
https://github.com/calabash-driver/grid-calabash-node-plugin
https://github.com/jenkinsci/selenium-plugin
https://github.com/groupon/Selenium-Grid-Extras
The text was updated successfully, but these errors were encountered: