def hacks_for_phantomjs(browser):
 if isinstance(browser, webdriver.PhantomJS):
  js = "\n            window.confirm = function(message) {\n                return true;\n            }\n            window.alert = window.prompt = window.confirm;\n\n            // REF: http://stackoverflow.com/questions/13536752/phantomjs-click-a-link-on-a-page?rq=1\n            // REF: http://stackoverflow.com/questions/2705583/how-to-simulate-a-click-with-javascript/2706236#2706236\n            window.eventFire = function(el, etype) {\n                if (el.fireEvent) {\n                    el.fireEvent('on' + etype);\n                } else {\n                    var evObj = document.createEvent('Events');\n                    evObj.initEvent(etype, true, false);\n                    el.dispatchEvent(evObj);\n                }\n            };\n\n            // shorter alternative of above method\n            window.simulateClick = function(el) {\n                var e = document.createEvent('MouseEvents');\n                e.initEvent( 'click', true, true );\n                el.dispatchEvent(e);\n            };\n        "
  browser.execute_script(('%s' % js))

def hacks_for_phantomjs ( browser ) : if isinstance ( browser , webdriver . PhantomJS ) : js = "\n            window.confirm = function(message) {\n                return true;\n            }\n            window.alert = window.prompt = window.confirm;\n\n            // REF: http://stackoverflow.com/questions/13536752/phantomjs-click-a-link-on-a-page?rq=1\n            // REF: http://stackoverflow.com/questions/2705583/how-to-simulate-a-click-with-javascript/2706236#2706236\n            window.eventFire = function(el, etype) {\n                if (el.fireEvent) {\n                    el.fireEvent('on' + etype);\n                } else {\n                    var evObj = document.createEvent('Events');\n                    evObj.initEvent(etype, true, false);\n                    el.dispatchEvent(evObj);\n                }\n            };\n\n            // shorter alternative of above method\n            window.simulateClick = function(el) {\n                var e = document.createEvent('MouseEvents');\n                e.initEvent( 'click', true, true );\n                el.dispatchEvent(e);\n            };\n        " browser . execute_script ( ( '%s' % js ) )
hack: if using phantomjs .