how to run commands in CMD prompt using robot framework

13,687

Solution 1

Although it would propably be more effective of use a custom Python library, it is possible to accomplish with regular Robot Framework:

*** Settings ***
Library    OperatingSystem
Library    String

*** Test Cases ***
Test IPConfig
    ${frt}=     Run     ipconfig | find "IPv4"
    ${IP}=    Fetch From Right    ${frt}    ${SPACE}
    Log To Console     [${IP}]

Solution 2

Create .bat file and write your commands in that. If your .bat file located in other folder then use cd commands and then your required commands

Example of bat file like

cd C:\robotFramework\runner

java abc.class

Use following Keyords

  1. Run xyz.bat : for this use Library OperatingSystem Or
  2. Run Process xyz.bat : for this use Library Process
Share:
13,687
vinu
Author by

vinu

Updated on June 14, 2022

Comments

  • vinu
    vinu almost 2 years

    How do i run the command 'ipconfig' in cmd prompt using robot framework. running below code gives me the complete result. I just need IPV4 Address.

    ${frt}= | Run | ipconfig
    Log ${frt}