Reputation: 1071
Has anyone found a method for executing their .py files from the Robot Framework like you can for JS?
RobotFramework:
Executes the given JavaScript code.
code may contain multiple statements and the return value of last statement is returned by this keyword.
code may be divided into multiple cells in the test data. In that case, the parts are catenated together without adding spaces.
If code is an absolute path to an existing file, the JavaScript to execute will be read from that file. Forward slashes work as a path separator on all operating systems. The functionality to read the code from a file was added in SeleniumLibrary 2.5.
Note that, by default, the code will be executed in the context of the Selenium object itself, so this will refer to the Selenium object. Use window to refer to the window of your application, e.g. window.document.getElementById('foo').
Example: Execute JavaScript window.my_js_function('arg1', 'arg2') Execute JavaScript ${CURDIR}/js_to_execute.js
It's bs that I can't run my .py files this way...
Upvotes: 1
Views: 728
Reputation: 17909
The Execute Javascript extension isn't a part of RobotFramework, it's something added by the Selenium integration, it would therefore follow that you can't use Selenium to execute a .py file.
That said, RobotFramework is written in Python and can obviously be extended with a Python script.
Can you clear up what you're actually trying to achieve here though? My concern is that if you're using a .py file in your test state to validate your code, isn't that introducing an uncertainty that means that what you're testing is not the same as the code that gets executed when you release your project?
A bit more detail would help a lot here!
Upvotes: 1