Rob Forrest
Rob Forrest

Reputation: 7450

Codeception Screenshots on test pass

I see that Codeception takes screenshots if a test fails, is there anyway to make it take screenshots if the tests pass too?

For info, we're using the phantomjs WebDriver.

Upvotes: 3

Views: 3680

Answers (2)

gekh
gekh

Reputation: 2122

You can use Recorder extension with option delete_successful in configuration acceptance.suite.yml (in extensions: part, not modules:)

extensions:
    enabled:
        - Codeception\Extension\Recorder:
            delete_successful: false # keep screenshots of successful tests

Quote from documentation about Recorder and PhantomJS:

Since PhantomJS doesn’t give you any visual feedback, it’s probably a good idea to install Codeception\Extension\Recorder which gives you screenshots of how PhantomJS “sees” your pages.

More information you can find in documentation for Recorder extension: http://codeception.com/extensions#Recorder

How to find screenchots

Results of the last test running you can find in a file _output/records.html. The file contains links to slideshows with screenshots for each test. Just reload the page after the test.

Upvotes: 2

Rob Forrest
Rob Forrest

Reputation: 7450

The best documentation for this I've found is for the WebDriver module

In there there's a description of makeScreenshot() which allows you to take a screenshot at any given point of your tests. It appears that it will put all of the screenshots in one directory so better think about a good naming convention.

Alternatively, we've now got the Recorder extension working which automates the process of taking screenshots at every test step and presents them in a useful report.

Upvotes: 4

Related Questions