O
O
Olga Belova2018-05-02 18:20:06
Python
Olga Belova, 2018-05-02 18:20:06

How to attach Sceenshot to HTLM report after passing the test?

Tell me how to attach Screenshot to HTLM report
Using HTLMTestRunner which generates a report after TestSuite completes - I would like to see a screenshot after everything like here - 5ae9ba5dbb250185004863.png
(from https://pypi.org/project/pytest-html/1.17.0/)
Now TestRunner looks like So

def TestRunner(base_url):
    print base_url

    suite = unittest.TestSuite()
    ##Add additional test suites as classes here:
    suite.addTests([
        unittest.defaultTestLoader.loadTestsFromTestCase(SmokeTestSuite)
    ])

    # Invoke TestRunner
    dir = os.getcwd()
    now = datetime.datetime.now()
    fp = file('./PATH-' + str(now.strftime("%B-%d-%Y %H-%M-%S")) + '.html', 'wb')
    # runner = unittest.TextTestRunner(buf)       #DEBUG: this is the unittest baseline
    runner = HTMLTestRunner(
        stream=fp,
        title='   PS-02-Full-Smoke-Test  ' + base_url,
        verbosity=0,
        description='Smoke test suite'
    )
    runner.run(suite)


TestRunner(base_url)

first, before the test,
import HTMLTestRunner
is used. HTMLTestRunner is used from
https://github.com/tungwaiyip/HTMLTestRunner
How to configure HTLM to have a screenshot?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question