It's all about the answers!

Ask a question

Using IBM JUnit Selenium adapter on RQM 4.0


1
1
Leandro trevis (37913) | asked Aug 08 '12, 8:39 a.m.
retagged Aug 10 '12, 8:02 a.m. by Nhi P Ta (18841018)
 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


permanent link
Thomas Neal (141133) | answered Aug 09 '12, 12:39 p.m.
JAZZ DEVELOPER
edited Aug 13 '12, 9:15 a.m.
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.

Leandro trevis selected this answer as the correct answer

5 other answers



permanent link
Leandro trevis (37913) | answered Aug 10 '12, 10:15 a.m.
 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!

permanent link
Thomas Neal (141133) | answered Aug 10 '12, 12:38 p.m.
JAZZ DEVELOPER
edited Aug 10 '12, 12:52 p.m.
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)



permanent link
Leandro trevis (37913) | answered Aug 13 '12, 2:59 p.m.
 yes that is it! The files did not have extension (linux) so I forced a '.png' and it worked

Thanks!

permanent link
Leandro trevis (37913) | answered Aug 10 '12, 1:34 p.m.
Hi
yes I guess it is Screenshots column, I did day screnn capture because I'm using a translated version 'Capturas de tela' :-)

In the shell windows when the test runs shows:
Progress: 0: Executing test: test(com.mypackage.Test1)

ExitCode: 0



permanent link
Thomas Neal (141133) | answered Aug 10 '12, 8:21 p.m.
JAZZ DEVELOPER
What are you naming your screenshot file(s)?  I should have mentioned that the adapter is looking only for image files, ie. files with the following suffixes, .png, .jpg, .jpeg, .gif, .tif, .bmp

Be sure the filename(s) you specify has one of those suffixes.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.