Raj Singh Rathore
Raj Singh Rathore

Reputation: 31

How to attach Screen shot in Robot framework report

I tried to attach screen shot in robot framework using Take Screenshot Keyword got an error like in logs

Taking screenshot failed: Taking screenshots is not supported on this platform by default. See library documentation for details.
Make sure tests are run with a physical or virtual display"

I use "Take Screenshot product.jpg 80%" in robot framework Test Cases

*** Settings ***
Library  File.py
Library  SeleniumLibrary
Library  SeleniumScreenshots
Library  Screenshot

*** Test Cases ***
Add product to the Shopping Cart
    Search the product in home page
    Select first product
    #Capture page screenshot  product.png
    Take Screenshot  product.jpg  80%
    Select the size of product
    Select the product to shopping cart
    Take Screenshot  Cart.png  80%

screenshot

Upvotes: 0

Views: 7294

Answers (2)

Konstantin V
Konstantin V

Reputation: 164

Try using capture page screenshot instead of take screenshot.

Upvotes: 0

Bryan Oakley
Bryan Oakley

Reputation: 386010

Take Screenshot (assuming you're using the keyword from the Screenshots library) takes a picture of the physical screen rather than the browser window. It only works if you have an actual (or virtual) screen attached to the process that is running the tests.

From the documentation for the Screenshots library:

Notice that successfully taking screenshots requires tests to be run with a physical or virtual display.

Upvotes: 1

Related Questions