selenium-iderun-script

Difference between runScrip and storeEval commands


I am a beginner in testing. I am doing my internship on testing and trying to learn about all the commands in selenium IDE. I would really appreciate if someone could help me. I want to know the difference between runScript and storeEval commands. I understand the basic difference by the reference but i want to know in detail. Thank you.


Solution

  • Try to do:

    runScript | somethingwrong
    storeEval | if (1==1) 'lol' //Or any valid js | somevar
    echo      | ${somevar}
    echo      | javascript{if (storedVars['somevar'] != 'lol') {'???';} else {'We can do js here too'}}
    storeEval | somethingwrong                    | somevar
    getEval   | somethingwrong
    verifyEval| storedVars['somevar'] == 'lol'    | true
    verifyEval| {if (1==1) true}                  | false
    

    And run each line with doubleclick one by one.

    runScript

    It's returning nothing. And it is not wrapped by selenium IDE. It means that wrong script will not cause any error in selenium IDE. But it will cause js error in the browser. It may be useful if you want to use browser debugging tools to treat some js error

    storeEval

    It is storing result of a javascript to a variable. And it is wrapped by Selenium IDE it means that broken script will cause error right in the Selenium IDE and test will be stopped in that case. You will be able read error right in the Selenium IDE log.

    echo

    Can run javascript too. But please do it for debugging only. If your js is broken it will hang the test.

    getEval

    It's returning no result. Everything else like in storeEval. Broken js will fail the test.

    verifyEval

    Is for verifying variables. It will fail the test in case if two evals provided are not equal. You can use to run javascript too. It is very useful when you need not only get the result of javascript but fail the test if your the result is not acceptable.

    So:

    runScript is to just do script and go further (maybe with errors in browser console)

    getEval is to run script and fail in case of something wrong

    storeEval is to run script and retrieve the result to use it later

    verifyEval is to run script and verify the result.

    echo is not for running scripts. But you can do it. For debugging only.

    There are a number of other ways to run script using Selenium IDE. But it's already a lot.

    Hope it will help.