Recently I am working on selenium webdriver 2.0 (developing automation framework). As per requirement for every faiulre the screenshot must be capture (file path and filename: ./screenshots/testcases/ddmmyyyy/scenario_hhmmss.png) however I already capture screenshots. when i run these entire test suite (I want to generate JUNIT report such that the repost must have screenshot link.)Now problem is that the screenshot path is generate dynamically (By selenium java code), and in Junit report i want to establish hyperlink to recently generated screenshots (i already updated frames-report.xslt file using we can create link but it was hardcoded)? Please suggest any way to do so?
Here is some part of my build.xml file
<target name="exec" depends="compile">
<delete dir="${report}" />
<mkdir dir="${report}" />
<mkdir dir="${report}/xml" />
<junit printsummary="yes" haltonfailure="no">
<classpath refid="project-classpath" />
<classpath>
<pathelement location="${bin}" />
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</classpath>
<test name="com.example.tests.NormanTestSuite" haltonfailure="no" todir="${report}/xml" outfile="TEST-result">
<formatter type="xml" />
</test>
</junit>
<junitreport todir="${report}">
<fileset dir="${report}/xml">
<include name="TEST*.xml" />
</fileset>
<report styledir="C:\apache-ant-1.8.4\custom" format="frames" todir="${report}/html" >
</report>
</junitreport>
</target>
According to the documentation of the JUnitReport task, you can pass XSL paramemeters using a nested
param
tag on thereport
element.So you could pass the parameter value to the stylesheet something like this:
I wasn't clear from your question. I think you said you have already supported the parameter in your XSL stylesheet. Anyway, here's a summary of how you can use it:
Using Java System Property
You can pass a variable as a JVM argument. Assuming you have a variable named "screenShotRoot" defined like this
you can read it in your build.xml like this
Your ANT task can then use this root path to generate appropriate paths to your PNG files on the date expected.
See this Apache ANT FAQ page
Using Environment Variables
You can also use Operating System environment variables, by setting them before calling your script. Assuming you have an environment variable named "screenShotRoot" defined like this on Windows
you can read it in your build.xml like this
Using Properties Files
You could also write your links into a properties file that your ANT script loads, like this