def METHOD_NAME(self, code):
    """ Execute script in the page context.
    Note that it seems that executing script directly does not access the wrapped functions but
    directly to the browser internals.
    """
    try:
        self.driver.METHOD_NAME(""" \
            let s = document.createElement("script"); \
            s.type = "text/javascript"; \
            s.text = '%s'; \
            document.head.appendChild(s);""" % code)
    except exceptions.JavascriptException as e:
        assert False, code