✓ Selenium 3.0.0 ✓ Java 8




Can Selenide take screenshots?

Yes, Selenide takes screenshots automatically on every test failure. This is very useful for error analysis.

By default Selenide puts screenshots to folder build/reports/tests.

Can I tell Selenide to put screenshots to a specific folder?

Yes. You can use property -Dselenide.reports=test-result/reports to set any directory to store screenshots to.

Another option is to set this folder directly from your code:

Configuration.reportsFolder = "test-result/reports";

JUnit and TestNG support

For JUnit and TestNG, there is a special support for taking screenshots also on successful tests.

For JUnit:

To automatically take screenshot of every failed test:

import com.codeborne.selenide.junit.ScreenShooter;

public ScreenShooter makeScreenshotOnFailure = ScreenShooter.failedTests();

Actually it’s rudiment. You don’t need it, because Selenide does it automatically.

But if you wish to automatically take screenshot of every test (even succeeded), use the following command:

public ScreenShooter makeScreenshotOnFailure = ScreenShooter.failedTests().succeededTests();

For TestNG:

import com.codeborne.selenide.testng.ScreenShooter;

@Listeners({ ScreenShooter.class})

To automatically take screenshots after every test (even succeeded), execute the following command before running tests: java ScreenShooter.captureSuccessfulTests = true;

At any moment you wish

Additionally, you can take screenshot at any moment with a single line of code:

import static com.codeborne.selenide.Selenide.screenshot;


Selenide will create two files: my_file_name.png и my_file_name.html

blog comments powered by Disqus

The project is maintained by