Skip to content

Commit

Permalink
Ignore infinite capture scrrenshot (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
atthaboon authored Feb 20, 2021
1 parent 8ffc823 commit 0fe79df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Examples/utilities/screenshot.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions PuppeteerLibrary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 0fe79df

Please sign in to comment.