Skip to content

Attach screenshot to reportportal #100

@AbdulAmrinSubair

Description

@AbdulAmrinSubair

As a user i cannot upload screenshots/files to reportportal via robotframework

Versions:-

  • robotframework-reportportal 5.1.0
  • reportportal-client 5.0.10
  • robotframework 4.0.2
  • requests 2.25.1

Below is the python class with add attachment logic

import subprocess
from robotframework_reportportal import logger
class Customlogger:
     
    def log_free_memory(self,name):
        with open(name, "rb") as fh:
         
            file_data = fh.read()
            logger.info("Collecting free memory statistics!")
            logger.info("Some Text Here",attachment={"name": "test_name_screenshot.png","data": file_data, "mime": "image/png"})
             

Below is the .robot file

*** Settings ***
Library           SeleniumLibrary   
Library           Collections
Library    Customlogger.py


*** Keywords ***
Capture image
   ${path}   Capture Page Screenshot
   Log Free Memory  ${path}


*** Test Cases ***
Sample Test
    Open Browser  https://www.google.com    chrome
    Capture image
            

Both the files are in the same folder structure.

Actual:-
Keywords and test are displayed in the reportportal except screenshots

Expected:-
Screenshot should be attached

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions