1

I am a new user and I didn't find a solution for a doubt about the execution of my script, wrote in python, in Robot Framework.

The script works when I execute it on python compiler but when I execute the test case on Robot Framework, this error is showed:

===========================================================================
TestProvaPower
===========================================================================
TestPowerAngelo                                                    | FAIL |
No keyword with name 'power' found.
---------------------------------------------------------------------------
TestProvaPower                                                     | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
===========================================================================
Output:  c:\users\user\appdata\local\temp\RIDEjtznzw.d\output.xml

I think that this error is shown because it is necessary to pass the arguments and parameters.

Please, how can I pass these values in Robot Framework?

The test suite is:

** Settings **
Library           ../../../../../Users/User/workspace/TestAngelo18.09/TestProva22.py

** Test Cases **
TestPowerAngelo
    power    base    exponent
    push    ${base}    ${exponent} 

While my Python script is:

base = input("Insert base")
exponent =input("Insert exponent")

def power(base,exponent):
    result=base**exponent
    print "%d to the power of %d is %d" %(base,exponent,result)

power (base,exponent)
2
  • Could you add your TestProvaPower suite to the question? It looks like you didn't import your python module correctly. Commented Sep 20, 2013 at 16:32
  • you should remove everything except the function from the library. the first, second and last line are only called only when the library is imported. Commented Oct 2, 2013 at 14:58

3 Answers 3

3

As part of your module definition, you are getting input from the user. When a module is being imported, you cannot use the standard input stream so an EOFError occurs. Below is a modified version of your library that is still testable via direct execution.

def power(base, exponent):
    result = base**exponent
    return result

if __name__ == '__main__':
    base = input("Insert base")
    exponent = input("Insert exponent")
    result = power(base,exponent)
    print "%d to the power of %d is %d" %(base, exponent, result)
Sign up to request clarification or add additional context in comments.

Comments

1

Instead of using complex path in the Library import try setting python path with pybot e.g.

pybot --pythonpath /path/to/libs/where/py/file/is

And in the test suite file import it using just the name e.g. without the .py suffix.

Library    TestProva22

1 Comment

Thanks guys, I deleted the input for base and exponent variables because I use Robotframework.
1

RF treats arguments as strings by default. For literals, you can surround them with ${} or variables use Convert To Integer first. Something like this should work:

${result} =  power   ${2}  ${4}
Should Be Equal As Integers  ${result}  16

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.