Skip to content

Commit

Permalink
Merge eb44df9 into d8a852c
Browse files Browse the repository at this point in the history
  • Loading branch information
izapolsk committed May 15, 2018
2 parents d8a852c + eb44df9 commit b8088d8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/widgetastic/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ def before_keyboard_input(self, element, keyboard_input):
"""
pass

def before_execute_script(self):
"""Invoked before executing execute_script.
"""
pass

def after_execute_script(self):
"""Invoked after executing execute_script.
"""
pass


class Browser(object):
"""Wrapper of the selenium "browser"
Expand Down Expand Up @@ -535,7 +547,15 @@ def execute_script(self, script, *args, **kwargs):
processed_args.append(arg.__element__())
else:
processed_args.append(arg)
return self.selenium.execute_script(dedent(script), *processed_args, **kwargs)

self.plugin.before_execute_script()
try:
output = self.selenium.execute_script(dedent(script), *processed_args, **kwargs)
except UnexpectedAlertPresentException:
output = None
pass
self.plugin.after_execute_script()
return output

def refresh(self):
"""Triggers a page refresh."""
Expand Down

0 comments on commit b8088d8

Please sign in to comment.