reportportal / agent-Python-RobotFramework

Robot Framework integration for Report Portal
Apache License 2.0
59 stars 33 forks source link

Attach screenshot to reportportal #100

Closed AbdulAmrinSubair closed 3 years ago

AbdulAmrinSubair commented 3 years ago

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

iivanou commented 3 years ago

@AbdulAmrinSubair Change your .robot file the way below and let us know the results. Thanks.

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

*** Test Cases ***
Sample Test
    Open Browser  https://www.google.com    chrome
    ${path}   Capture Page Screenshot
    Log Free Memory  ${path}
AbdulAmrinSubair commented 3 years ago

Screen Shot 2021-05-12 at 9 41 46 AM

@iivanou no screenshot attached yet

iivanou commented 3 years ago

@AbdulAmrinSubair Can you apply changes from #101? They should fix the problem.

AbdulAmrinSubair commented 3 years ago

@iivanou i tried but nothing changed pip install git+https://github.com/iivanou/agent-Python-RobotFramework.git@screenshots

iivanou commented 3 years ago

image image

AbdulAmrinSubair commented 3 years ago

@iivanou i confirm that screenshot works now! but if this logic is defined inside * Keywords screenshot attach doesn't happen

AbdulAmrinSubair commented 3 years ago

@iivanou i think the issue is due to https://github.com/reportportal/agent-Python-RobotFramework/issues/102

AbdulAmrinSubair commented 3 years ago

@iivanou

100 issue still exists

Screen Shot 2021-05-14 at 1 43 26 PM

tried version robotframework-reportportal v5.1.1 but still screenshots aren't attached

102 is fixed

iivanou commented 3 years ago

Version 5.1.1 has not been released yet.