Reputation: 21
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)
Upvotes: 1
Views: 7287
Reputation: 1849
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
Upvotes: 1
Reputation: 2384
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)
Upvotes: 3
Reputation: 876
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
Upvotes: 1