Dani
Dani

Reputation: 183

Robot Framework: Unable to set screeshot directory and view custom screenshot in the log file

I am trying to run the below code to save the screenshot of all the failed test cases in the Test Suite to a custom folder and to view the screenshots in the log file. The below code doesn't run as expected .Please help in completing the code.

'*** Setting ***
Suite Setup    register    
Test Setup    Set Screenshot Directory    D:/path/  
Library        Selenium2Library


*** Keywords ***
sc    
    Capture page screenshot    D:/path/

register
    Register Keyword To Run On Failure    sc

*** Test Cases ***
Run TestCase1
    Open Browser    http://google.com    chrome

    Click Element    css=getsomthing


Run TestCase2
    Open Browser    http://google.com    chrome

    Run Keyword And Continue On Failure  Click Element    css=getsomthingother   '

When executing I get the following error [ WARN ] Keyword 'sc' could not be run on failure: Failed to save screenshot file:///D:/path

Upvotes: 0

Views: 2067

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386210

You seem to be giving capture page screenshot the name of a folder when it expects the name of a file. It probably fails because it can't create a screenshot file with the name of an existing directory.

Since you already set the screenshot directory to D:/path, there's no need to give a filename to capture page screenshot.

Upvotes: 0

Related Questions