I’m struggling to create png screenshots after every successful @Test completes and including those screenshots in my allure report.
Please help.
I’ve tried to put the below under my public class but then the test never finishes and I’m forced to stop the run and only then a test is created but as an xml file.
@RegisterExtension
static
ScreenShooterExtension
screenshotEmAll
=
new
ScreenShooterExtension(true).to(System.getProperty("user.dir")
+ "/screenshots");
![]() | Andre Steenkamp Senior Test Analyst |
C: +27 82 923 9140 | T: +27 21 525 3100 An...@switch.tj | transactionjunction.co.za | |
The information in this message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this message by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful. Please immediately contact the sender if you have received this message in error. Thank you.
--
You received this message because you are subscribed to the Google Groups "selenide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenide+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenide/JNZP275MB1498F0881F183CA33CEFA81BA4A7A%40JNZP275MB1498.ZAFP275.PROD.OUTLOOK.COM.
Hi Andrei,
I had this config just not the extra screenshots and savePageSource properties which I have added but I see no difference and no screenshots.
@BeforeAll
static void
setupAllureReports() {
SelenideLogger.addListener("AllureSelenide",
new
AllureSelenide()
.screenshots(true)
.savePageSource(true)
);
}
I would love to take a screenshot after every @Test block before I move on to the next @Test.
Andre Steenkamp Senior Test Analyst |
C: +27 82 923 9140 | T: +27 21 525 3100 An...@switch.tj | transactionjunction.co.za |
I’ve found a way to attach a screenshot to the Allure report, below is just a static png file that I attach if I call this function.
@Attachment(value
=
"screenshot",
type
=
"image/png",
fileExtension
=
".png")
public byte[]
attachScreenshotPNG()
throws
IOException,
IOException
{
return
Files.readAllBytes(Paths.get(System.getProperty("user.dir")+
"/screenshots/image.png"));
}
So how can I create a png screenshot file after every test?
I can then just pass the location to this function to attach to the Allure report.
I’ve tried adding this but then my tests just hang and it never gets past the first test.
It’s like it cannot take the screenshot and just sits there.
@AfterEach
void
takeScreenshot(){
Selenide.screenshot(new
Date().toString());
}
I’m not sure if it is because I’m interacting with an apk on an Android device and if it is not possible to take screenshots?
Andre Steenkamp Senior Test Analyst |
C: +27 82 923 9140 | T: +27 21 525 3100 An...@switch.tj | transactionjunction.co.za |
From: Andre Steenkamp
Sent: Thursday, November 2, 2023 9:52 AM
To: Andrei Solntsev <andrei....@gmail.com>
Cc: selenide <sele...@googlegroups.com>
Subject: RE: Screenshots after every test
I’ve found a way to attach a screenshot to the Allure report, below is just a static png file that I attach if I call this function.
@Attachment(value
=
"screenshot",
type
=
"image/png",
fileExtension
=
".png")
public byte[]
attachScreenshotPNG()
throws
IOException,
IOException
{
return
Files.readAllBytes(Paths.get(System.getProperty("user.dir")+
"/screenshots/image.png"));
}
So how can I create a png screenshot file after every test?
I can then just pass the location to this function to attach to the Allure report.
From: Andrei Solntsev <andrei....@gmail.com>
I think I have some other issue here because if I look at the Appium logs it gets to this point and then just hangs here.
I am causing a failure by having an incorrect element to ensure it doesn’t find it.
[debug] [AndroidUiautomator2Driver@3542 (01c15334)] Calling AppiumDriver.getScreenshot() with args: ["01c15334-b14d-4641-8f17-6026a95b200b"]
[debug] [AndroidUiautomator2Driver@3542 (01c15334)] Matched '/screenshot' to command name 'getScreenshot'
[debug] [AndroidUiautomator2Driver@3542 (01c15334)] Proxying [GET /screenshot] to [GET http://127.0.0.1:8200/session/83a784ab-0da2-48ce-87fe-85ad3844e913/screenshot] with no body
Andre Steenkamp
Senior Test Analyst
The information in this message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this message by anyone else is unauthorised.If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful.Please immediately contact the sender if you have received this message in error.Thank you.
The information in this message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this message by anyone else is unauthorised.If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful.Please immediately contact the sender if you have received this message in error.Thank you.
This can be ignored I finally realised what my issue is.
It is not allowed on the device I’m using and I only realised that when I looked at the Logcat logs and there it throws an exception when attempting a screenshot.
Thanks for all the assistance though!
Andre Steenkamp Senior Test Analyst |
C: +27 82 923 9140 | T: +27 21 525 3100 An...@switch.tj | transactionjunction.co.za |
From: Andre Steenkamp
Sent: Friday, November 3, 2023 10:54 AM
To: Andrei Solntsev <andrei....@gmail.com>
Cc: selenide <sele...@googlegroups.com>
Subject: RE: Screenshots after every test
I think I have some other issue here because if I look at the Appium logs it gets to this point and then just hangs here.
I am causing a failure by having an incorrect element to ensure it doesn’t find it.
[debug] [AndroidUiautomator2Driver@3542 (01c15334)] Calling AppiumDriver.getScreenshot() with args: ["01c15334-b14d-4641-8f17-6026a95b200b"]
[debug] [AndroidUiautomator2Driver@3542 (01c15334)] Matched '/screenshot' to command name 'getScreenshot'
[debug] [AndroidUiautomator2Driver@3542 (01c15334)] Proxying [GET /screenshot] to [GET http://127.0.0.1:8200/session/83a784ab-0da2-48ce-87fe-85ad3844e913/screenshot] with no body
From: Andrei Solntsev <andrei....@gmail.com>