Skip to content

Commit 52d8f50

Browse files
committed
Improve run on failure functionality
When run on failure keyword is capture page screenshot execute is method and not as keyword
1 parent 2f46608 commit 52d8f50

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

atest/acceptance/keywords/run_on_failure.robot

+10
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ Run On Failure also fails
7373
... ${FAILURE MESSAGE}
7474
... Page Should Not Contain needle loglevel=None
7575

76+
Run On Failure With Default Keyword And Conflight With Keyword Names
77+
[Documentation] LOG 2.1 INFO REGEXP: .*<a href=\\"selenium-screenshot.*\\.png\\"><img src=\\"selenium-screenshot.*\\.png\\" width=\\"800px\\"></a>.*
78+
Register Keyword To Run On Failure Capture Page Screenshot
79+
Run Keyword And Expect Error
80+
... ${FAILURE MESSAGE}
81+
... Page Should Not Contain needle loglevel=None
82+
7683
*** Keywords ***
7784
On Fail
7885
${count}= Evaluate ${ON FAIL COUNT} + 1
@@ -87,3 +94,6 @@ Open Browser To Front Page
8794

8895
Failure During Run On failure
8996
Fail Expected error.
97+
98+
Capture Page Screenshot
99+
Fail This should not be never run

src/SeleniumLibrary/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,10 @@ def failure_occurred(self):
544544
return
545545
try:
546546
self._running_on_failure_keyword = True
547-
BuiltIn().run_keyword(self.run_on_failure_keyword)
547+
if self.run_on_failure_keyword.lower() == "capture page screenshot":
548+
self.capture_page_screenshot()
549+
else:
550+
BuiltIn().run_keyword(self.run_on_failure_keyword)
548551
except Exception as err:
549552
logger.warn(
550553
f"Keyword '{self.run_on_failure_keyword}' could not be run on failure: {err}"

0 commit comments

Comments
 (0)