1

I am having trouble output/saving the results from my terminal commands.

*** Settings ***
Library     Process
Suite Teardown      Terminate All Processes     kill=True

*** Test Cases ***
Example
    Run Process   adb devices -l

Current Output

enter image description here

Expected Output

However, if i just run adb devices -l, it will provide me with a list of android devices id.

E.g. List of devices attached 0429329319 device usb: xxxx

My attempts

  1. Based on the robot framework, it has this example that i tried to follow but gave me errors such as "No keyword with name ${result} = Run Process found"

Sample code from robot framework

${result} = Run Process program stdout=${TEMPDIR}/stdout.txt    stderr=${TEMPDIR}/stderr.txt
Log Many    stdout: ${result.stdout}    stderr: ${result.stderr}    
  1. Another way that i have discovered is to use 'Get Process Result' keyword.

So my question is - how do i print/save the output of my terminal commands?

Would appreciate if anyone can take a look at it

Referenced to

JAYY
  • 440
  • 9
  • 34
  • where is code you tried? _ it has this example that i tried to follow_ after this there is only error not a code you tried. – Dev May 27 '19 at 06:12
  • 1
    Hi @Dev , thanks for ur response! I just found out the answer to my question. Will be updating this answer section shortly :) – JAYY May 27 '19 at 06:25
  • 2
    the error ` "No keyword with name ${result} = Run Process found"` means you only have a single space after `=`. You need to have two or more spaces. – Bryan Oakley May 27 '19 at 22:24

1 Answers1

1

I just found out one way would be using the OperatingSystem library - 'Run'.

Then log the results of the command entered into the terminal/command prompt using 'Log To Console'

*** Settings ***
Library             OperatingSystem

*** Test Cases ***
Get list of devices
    ${result} =     Run     adb devices -l
    Log To Console  [${result}]

To save the printed stuff in the console, just do robot xx.robot > console.txt

Referenced to - how to run commands in CMD prompt using robot framework

JAYY
  • 440
  • 9
  • 34