Using IBM JUnit Selenium adapter on RQM 4.0
Hi, I've almost successfully configured the JUnit Selenium adapter running with my RQM 4 test environment.
I can run the test class and return the results.
The only problem is that the error printscreen is not returning with the test results in RQM.
I've had followed the instructions on
Is there any extra config I need to do in order to get the printscreen when some test fails?
Accepted answer
Hi Leandro, if your JUnit Selenium testcase is taking screenshots and you want to attach them to the execution result you can do this by writing the screenshot file to the directory specified by the Java System property named "selenium.screenshot.dir". After each JUnit test is executed this directory is scanned for new image files and any found are attached to the execution result and associated with the corresponding test. You could create a small method like the following to do this.
private void takeScreenShot(String fname) throws Exception {
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String imageFileDir = System.getProperty("selenium.screenshot.dir");
if (imageFileDir == null)
imageFileDir = System.getProperty("java.io.tmpdir");
FileUtils.copyFile(scrFile, new File(imageFileDir, fname));
}
The details about selenium.screenshot.dir missed getting into the RQM 4.0 documentation but should be present in the 4.0.0.1 version of the docs.
Note that the adapter will only look for image files, ie. files with the following suffixes, .png, .jpg, .jpeg, .gif, .tif, .bmp. Be sure the names you specify include one of these.
private void takeScreenShot(String fname) throws Exception {
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String imageFileDir = System.getProperty("selenium.screenshot.dir");
if (imageFileDir == null)
imageFileDir = System.getProperty("java.io.tmpdir");
FileUtils.copyFile(scrFile, new File(imageFileDir, fname));
}
The details about selenium.screenshot.dir missed getting into the RQM 4.0 documentation but should be present in the 4.0.0.1 version of the docs.
Note that the adapter will only look for image files, ie. files with the following suffixes, .png, .jpg, .jpeg, .gif, .tif, .bmp. Be sure the names you specify include one of these.
5 other answers
Thanks Thomas,
I used the code above and succesfully wrote screenshot files on selenium.screenshot.dir. But the adapter is not uploading these images within the results.
On the result report on RQM the colum Screen capture remains empty.
Can this be an issue with the adapter, wich is fairly new? Is there any patch or new version planned for this adapter?
tks!
Leandro,
Do you see any messages in the shell window where you started the JUnit Selenium adapter?
If everything is working correctly, you should see something similar to the following in the Result Details section of the Execution Result. You mention a column named "Screen capture", it should say "Screenshots", is that what you meant? (The image of the Execution Result I included in the comment editor is not showing up after I post)
Do you see any messages in the shell window where you started the JUnit Selenium adapter?
If everything is working correctly, you should see something similar to the following in the Result Details section of the Execution Result. You mention a column named "Screen capture", it should say "Screenshots", is that what you meant? (The image of the Execution Result I included in the comment editor is not showing up after I post)