Capture html just before an error execution?

37 views
Skip to first unread message

Ana MB

unread,
Dec 5, 2017, 7:24:27 AM12/5/17
to Jenkins Users
Hi guys!

Does anybody know how to capture the html/url before an error appear in the test case??
I need to know the previous URL, and I don't know how...

Thanks so much for your help!!!

Ana MB

unread,
Dec 5, 2017, 7:34:37 AM12/5/17
to Jenkins Users
I need some shell command to take a screenshoot and save in some directory. 
How could be that shell code?

Thanks so much!!

Ana MB

unread,
Dec 5, 2017, 7:48:16 AM12/5/17
to Jenkins Users
I've tried with:

screenCapture  **/captura.png

But it did'nt work...

Victor Martinez

unread,
Dec 5, 2017, 9:48:05 AM12/5/17
to Jenkins Users
Hi Ana,

Can you please explain deeply what you are trying to achieve? I don't really understand what you need though, and what tech stack you are using atm 

Cheers
Message has been deleted

Ana MB

unread,
Dec 7, 2017, 3:54:46 AM12/7/17
to Jenkins Users
I've tried with this plugin: https://wiki.jenkins.io/display/JENKINS/UI+Test+Capture+Plugin
But I can't configure it, it doesn't let me do it... why? I show you in the picture:

Does anybody knows why?

Thanks so much for your help!

El martes, 5 de diciembre de 2017, 13:34:37 (UTC+1), Ana MB escribió:

Ana MB

unread,
Dec 7, 2017, 5:10:09 AM12/7/17
to Jenkins Users
I show you another picture of the fail execution of the plugin:


Could anybody help me? Thanks guys!!!!

Ana MB

unread,
Dec 7, 2017, 6:12:43 AM12/7/17
to Jenkins Users
I've written the following to my test case java file:

String actualTest = this.getClass().getName()+"."+testname.getMethodName();
File scrFile = ((TakesScreenshot)FabricaWebDriver.getDriver()).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("target/screenshots/"+actualTest+".png"));










And it work!

Ana MB

unread,
Dec 7, 2017, 7:27:32 AM12/7/17
to Jenkins Users
But it work only when a test is SUCCESS. 
I need it when a test is FAILED,...... and I'm not able to get it.

I've tried with this conditions, but it doesn't work and I don't understand why...


My test result is the following:


Any help, please? :(

Ana MB

unread,
Dec 11, 2017, 3:10:35 AM12/11/17
to Jenkins Users
Does anybody know why is it happening?

Thanks so much!!! 

Ana MB

unread,
Dec 11, 2017, 4:31:39 AM12/11/17
to Jenkins Users
Well,... I've realized that it can't be work if the test fails because in this case, the tests doesn't finish and doesn't call to "takeScreenshot()" method in the code....

So... what could be the solution to take a screenshot of a webpage in case the test fails???

Thanks so much!!!!


El jueves, 7 de diciembre de 2017, 13:27:32 (UTC+1), Ana MB escribió:

Ana MB

unread,
Dec 11, 2017, 5:34:54 AM12/11/17
to Jenkins Users
Done! with this:

                 try{
driver.findElement(By.xpath(".//*[@id='reserva']")).click();
}
catch (Exception e) {
takeScreenshot(driver,e);
}
finally {
driver.close();
}

It works!
Reply all
Reply to author
Forward
0 new messages