0
votes

I am new to Robot Framework so I need help with this I am trying to do "RUN KEYWORD IF" ,if I look in docs they give Run Keyword If | '${status}' == 'PASS' | Some Action arg.

My doubt is with this PASS value . How to get this as every time I Try ,I get a none value for every Keyword statement. I am trying to do something this :

*** Settings ***

*** Variables ***
${name}      theon

*** Test Cases ***
Verify
    ${x}=    Set Variable    function
    Run Keyword If    '${x}==PASS'    Log 'True'
    ...    ELSE    Log    'False'

*** Keywords ***
function
    ${return}=    Should Equal    ${name}    theon
    [Return]    ${return}

I get error that x is defined NONE then how I can validate in the condition that my keyword is success or True.

I would also like some help with whether I can use a self defined keyword in place of 'condition' to run some keyword.

RUN KEYWORD IF|| Some self keyword here which return me pass or true|| Target Keyword

2

2 Answers

0
votes

What does Should Equal do? Since it does not exist in RF there is Should Be Equal but this just passes or fails the test. Note all Should... behave like this.

Maybe you want the evaluate if ${name} and theon are equal (the same) then use evaluate ...

${return}=    evaluate    '${name}'=='theon'

Evaluate will return True or False

Then this will work.

Run Keyword if    ${x}    Log    True
0
votes

Instead of "status", you can provide the "conditions" directly and then take a specific action using the "self defined keyword"

An example below :

Run Keyword if  ${medicine_expiry_year} > 2000 and ${medicine_expiry_year} < 2016    Send Mail to Company   ${company_mail_id}
Run Keyword if  ${medicine_expiry_year} == 2016  Report Remaining Months to Store operator  ${month_of_expiry}  
Run Keyword if  ${medicine_expiry_year} > 2016   Log     "Keep the medicine"

Conditions in Above Example :

${medicine_expiry_year} > 2000 and ${medicine_expiry_year} < 2016  
${medicine_expiry_year} == 2016
${medicine_expiry_year} > 2016

Self defined keywords with parameters :

Sends a Mail to Company using keyword "send Main to Company" with the mail id provided in "${company_mail_id}"

 Send Mail to Company   ${company_mail_id} 

Report the Remaining Months to Store operator using the keyword "Report the Remaining Months to Store operator" expiry month provided using variable "${month_of_expiry} "

Report Remaining Months to Store operator  ${month_of_expiry}   

Just Log the message using the keyword

Log  "Keep the medicine"

Hope so this was helpful.