def evaluate_js(script, uid='master'): """ Evaluate given JavaScript code and return the result :param script: The JavaScript code to be evaluated :param uid: uid of the target instance :return: Return value of the evaluated code """ escaped_script = 'JSON.stringify(eval("{0}"))'.format(escape_string(script)) return gui.evaluate_js(escaped_script, uid)
def evaluate_js(script): """ Evaluate given JavaScript code and return the result :param script: The JavaScript code to be evaluated :return: Return value of the evaluated code """ try: _webview_ready.wait(5) return gui.evaluate_js(script) except NameError: raise Exception( "Create a web view window first, before invoking this function")
def evaluate_js(script): """ Evaluate given JavaScript code and return the result :param script: The JavaScript code to be evaluated :return: Return value of the evaluated code """ try: _webview_ready.wait(5) assert gui.is_running() return gui.evaluate_js(script) except NameError: raise Exception("Create a web view window first, before invoking this function") except AssertionError: raise Exception("Cannot call function: the webview has been closed")
def evaluate_js(script, uid='master'): """ Evaluate given JavaScript code and return the result :param script: The JavaScript code to be evaluated :param uid: uid of the target instance :return: Return value of the evaluated code """ try: _webview_ready.wait(5) return gui.evaluate_js(script, uid) except NameError: raise Exception('Create a web view window first, before invoking this function') except KeyError: raise Exception('Cannot call function: No webview exists with uid: {}'.format(uid))
def load_css(stylesheet, uid='master'): code = css.src % stylesheet.replace('\n', '').replace('\r', '').replace('"', "'") gui.evaluate_js(code)