diff --git a/Examples/utilities/screenshot.robot b/Examples/utilities/screenshot.robot index e2d4c1d..5d67789 100644 --- a/Examples/utilities/screenshot.robot +++ b/Examples/utilities/screenshot.robot @@ -18,6 +18,10 @@ Capture page screenshot Set page screenshot path Set Screenshot Directory ./logs Capture Page Screenshot + +Capture page screenshot should not run again if keyword failed + Close All Browser + Run Keyword And Expect Error * Capture Page Screenshot *** Keywords *** Open browser to test page diff --git a/PuppeteerLibrary/__init__.py b/PuppeteerLibrary/__init__.py index a71a609..dc4f73e 100644 --- a/PuppeteerLibrary/__init__.py +++ b/PuppeteerLibrary/__init__.py @@ -116,7 +116,7 @@ def __init__(self, disable_python_logging=True): if disable_python_logging: self._disable_python_logging() - signal.signal(signal.SIGINT, self.signal_handler) + signal.signal(signal.SIGINT, self.terminal_signal_handler) try: self.loop = asyncio.get_event_loop() @@ -193,7 +193,8 @@ def run_keyword(self, name, args, kwargs): try: return DynamicCore.run_keyword(self, name, args, kwargs) except Exception: - self.failure_occurred() + if name.lower().replace(' ', '_') != 'capture_page_screenshot': + self.failure_occurred() raise finally: self._running_keyword = None @@ -205,7 +206,7 @@ def failure_occurred(self): logger.warn("Keyword '%s' could not be run on failure: %s" % (self.run_on_failure_keyword, err)) - def signal_handler(self, sig, frame): + def terminal_signal_handler(self, sig, frame): print('You pressed Ctrl+C!') BuiltIn().run_keyword_and_ignore_error('Close Puppeteer') sys.exit(0)