@step('I will confirm all alerts')
def i_confirm_all_alerts(step):
 world.browser.execute_script('window.confirm = function(){return true;} ; window.alert = function(){return;}')

@ step ( 'I will confirm all alerts' ) def i_confirm_all_alerts ( step ) : world . browser . execute_script ( 'window.confirm = function(){return true;} ; window.alert = function(){return;}' )
please note: this method must be called right before an expected alert window variables are page local and thus all changes are removed upon navigating to a new page in addition .