PLEASE NOTE THAT THIS HAS BEEN TESTED IN SELENIUM 2.X , SELENIUM 3.X COULD HAVE BREAKING CHANGES , The Idea is same though
Configuration Steps
- Create a new folder (for example named recorder)
- Download the jar (grid-video-recorder.jar) into the folder(recorder)
- Download the selenium standalone server .jar into the folder(recorder)
- Download monte media library jar file from https://www.randelshofer.ch/monte/ into the folder (recorder)
- launch the selenium hub with the following command "java -cp *:. org.openqa.grid.selenium.GridLauncher -role hub"
- launch the selenium node with the following command "java -cp *:. org.openqa.grid.selenium.GridLauncher -role node -proxy io.nirvagi.utils.node.proxy.ScreenRecordingProxy -servlets io.nirvagi.utils.servlet.RecorderServlet"
The recorder uses two desired capabilities node_screen_recording which must be set to true to enable recording . By default the recorder stops recording after 180 seconds . This can be configured with the desired capabiliy node_recording_timeout. The following example in java demonstrates how to use the recorder
public static void main(String args[]) throws Exception{
DesiredCapabilities caps = DesiredCapabilities.firefox();
// Enable screen recording
caps.setCapability("node_screen_recording", true);
// Set the recorder timeout to 60 seconds, The Screen recording will be stopped after 60 seconds
caps.setCapability("node_recording_timeout", 60);
RemoteWebDriver d = new RemoteWebDriver(new URL("https://localhost:4444/wd/hub"), caps);
d.get("https://www.google.com");
// Your screen recording would have ended here
d.quit();
}
The recording can be viewed by accessing the node (For example assuming that the node is running in localhost , the video files can be viewed at localhost:5555/extra/RecorderServlet)
Points to remember
- The recording happens at OS level , So if two test sessions are run parallely in the same node, The first session to start the recording will get handle to the recorder and will be able to stop it
- If the browser is minimized, due to some reason the recording cannot capture what is happening