2

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}  
vinu
  • 191
  • 2
  • 7
  • 22
  • 2
    Create a python file which does this logic for you, and then call the library. Robot does not have something like this built in... – Goralight Mar 17 '17 at 09:13
  • A reliable [python cross-platform solution](http://stackoverflow.com/a/28950776/3446126) to get the local ip - anything based on `ifconfig`/`ipconfig`/`ip addr` is OS specific, and greping the output is error prone. – Todor Minakov Apr 22 '17 at 06:16

2 Answers2

4

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}]
A. Kootstra
  • 6,827
  • 3
  • 20
  • 43
1

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