'Executes the given JavaScript code.
`code` may contain multiple lines of code and 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 JavaScript executes in the context of the currently selected
frame or window as the body of an anonymous function. Use _window_ to
refer to the window of your application and _document_ to refer to the
document object of the current frame or window, e.g.
_document.getElementById(\'foo\')_.
This keyword returns None unless there is a return statement in the
JavaScript. Return values are converted to the appropriate type in
Python, including WebElements.
Examples:
| Execute JavaScript | window.my_js_function(\'arg1\', \'arg2\') |               |
| Execute JavaScript | ${CURDIR}/js_to_execute.js            |               |
| ${sum}=            | Execute JavaScript                    | return 1 + 1; |
| Should Be Equal    | ${sum}                                | ${2}          |'

@keyword
def execute_javascript(self, *code):

    js = self._get_javascript_to_execute(''.join(code))
    self.info(('Executing    JavaScript:\n%s' % js))
    return self.browser.execute_script(js)
