Sample-ExpectLibrary

Setting Value
Library org.tonylin.robotframework.expect.ExpectUtil
Library OperatingSystem
Test Case Action Arguments
Test Expect Set OS Environment Var
${terminal_cmd} Set Variable If '%{OS_NAME}' == 'windows' cmd
... '%{OS_NAME}' == 'linux' /bin/sh
${id1} spawn ${terminal_cmd}
Set Expect Timeout 5
${id2} spawn ${terminal_cmd}
Set Expect Timeout 5
Should Not Be Equal ${id1} ${id2}
Send Command echo 1234
${result} Expect Should Contain 555
Should Be True '${result}'=='FAIL'
Send Command echo 7890
${result} Expect Should Contain 7890
Should Be True '${result}'=='PASS'
${result} Expect Should Contain 7890
Should Be True '${result}'=='FAIL'
Send Command echo 7890
Switch Spawn ${id1}
${result} Expect Should Contain 7890
Should Be True '${result}'=='FAIL'
Close Spawn
Switch Spawn ${id2}
Close Spawn
Keyword Action Arguments
Set OS Environment Var ${OS_NAME} Get Environment Variable OS_NAME ${EMPTY}
${os} Run Keyword If '${OS_NAME}' == '' Run And Return Rc
... ls
${OS_NAME} Set Variable If '${os}'=='0' linux
... '${os}'=='1' windows
Set Environment Variable OS_NAME ${OS_NAME}