Take screenshot filename argument failing when registered to be run on failure
Like agreed here #1396 reporting this.
Describe the bug Take screenshot filename argument failing when registered to be run on failure:
[ WARN ] Keyword 'Take Screenshot filename=robotframework-browser-screenshot-{index}' could not be run on failure:
take_screenshot() got multiple values for argument 'filename'
Trace log:
Traceback (most recent call last):
File "c:\python37\lib\site-packages\Browser\browser.py", line 880, in run_keyword
raise e
File "c:\python37\lib\site-packages\Browser\browser.py", line 870, in run_keyword
return DynamicCore.run_keyword(self, name, args, kwargs)
File "c:\python37\lib\site-packages\robotlibcore.py", line 94, in run_keyword
return self.keywords[name](*args, **(kwargs or {}))
File "c:\python37\lib\site-packages\Browser\keywords\waiter.py", line 93, in wait_for_elements_state
selector, state, timeout, self.strict_mode
File "c:\python37\lib\site-packages\Browser\keywords\waiter.py", line 132, in _wait_for_elements_state
logger.info(response.log)
File "c:\python37\lib\contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "c:\python37\lib\site-packages\Browser\playwright.py", line 153, in grpc_channel
raise AssertionError(error.details())
Working fine for positional argument.
To Reproduce Here look at a code snippet:
Take screenshot filename argument failing when registered to be run on failure
[Setup] New Page https://www.yahoo.com/
Browser.Register Keyword To Run On Failure Take Screenshot filename=robotframework-browser-screenshot-{index}
Click //button[@name="agree"]
Wait Until Network Is Idle
Wait For Elements State ddd
[Teardown] Close Page
Expected behavior Filename argument should be processed correctly and desired filename and path should be set.
Desktop (please complete the following information):
- OS: Windows 10 Enterprise Version 21H2 OS build 19044.1415
- OS: Docker image rfbrowser-stable:v11.1.1
- Browser: Chrome Version 97.0.4692.71 (Official Build) (64-bit)
Additional context Please find attached logs
@allcontributors please add @tomekTieto for bugs.
@aaltat
@tomekTieto already contributed before to bug
That should work, but looks like it doesn't.
I'm seeing what I believe is the same error on a Bitbucket Pipelines container.
There seems to be an error in the code snipped above. Adding Browser also in front of Take Screenshot it works, which means in the above code some other Take Screenshot keyword was used:
Browser.Register Keyword To Run On Failure Browser.Take Screenshot filename=
However, I have another problem, not sure if this should be another issue. When using the full path instead of file name, it does not work:
Browser.Register Keyword To Run On Failure Browser.Take Screenshot filename=${OUTPUT DIR}/screenshots/failed/robotframework-browser-screenshot-{index}
The output is:

Taking a screenshot with the same arguments, normally not on failure, it works.
This is not fixed, opening
Fuond the reason, code in https://github.com/MarketSquare/robotframework-browser/blob/main/Browser/browser.py#L909 is too naive and makes wrong assumption. Instead code should look argspec more closely and make better decision about argument types.