You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Take Screenshot doesn't process arguments correctly when run on failure #1356
Bug description
Take Screenshot doesn't process arguments correctly when it's registered to be run on failure. Normally when called explicitly it's working fine. Because of that as example unable to take fullPage screenshot.
Steps To Reproduce
Look at my 2 code snippets below:
Take Screenshot not working correctly when registered to run on failure
[Setup] New Page https://www.yahoo.com/
Browser.Register Keyword To Run On Failure Take Screenshot fullPage=True
Click //button[@name="agree"]
Wait Until Network Is Idle
Wait For Elements State ddd state=visible
[Teardown] Close Page
Take Screenshot working correctly when explicitly called
[Setup] New Page https://www.yahoo.com/
Click //button[@name="agree"]
Wait Until Network Is Idle
Take Screenshot fullPage=True
[Teardown] Close Page
Expected behavior
Take Screenshot should take full page screenshot for both examples.
Screenshots
Incorrect - screenshot taken from viewport as default. Notice that filename was taken from the argument fullPage=True
Correct - full page screenshot. File name correct according to default filename argument
Desktop:
OS: Windows 10 / docker image rfbrowser-stable:v8.0.1
Browser Chrome
Version 94.0.4606.61
Additional context
Checked other KWs to be registered on failure with arguments like Log and they're working correctly.
This is true, we do not do conversion, we just take arguments as they are, which in this case is plain strings and feed them forward. When we run keyword, we did expect that Robot Framework has done argument conversion and do not check any of the arguments.
The problem is that if there is keyword which is not keyword from this library, we do know the arguments types and therefore we can not do argument conversion. But it might be possible to do argument conversion for keywords which are from this library.
So there is two fixes:
Do argument conversion for keywords which are ours.
Document that only keywords from library has arguments converted automatically.
Even with that bug fixed we need to conversion for the arguments internally. Library relies on RF to the conversion when methods are run as keywords but for this usage case we need to do the conversion internally. Will look some RF api to do it, because argument conversion is pretty complex problem.
Now Register Keyword To Run On Failure will return an object which contains keywords name and args. Instead of the old keyword name. That is BICWIC change.
Hello @aaltat now I'm experiencing an issue: [ WARN ] Keyword 'Take Screenshot ('fullPage', True)' could not be run on failure: 'tuple' object has no attribute 'upper'
same with all possible arguments.
Tested on my local Windows environment and on browser-docker image.
Activity
aaltat commentedon Sep 30, 2021
@all-contributors please add @tomekTieto for bugs
allcontributors commentedon Sep 30, 2021
@aaltat
I've put up a pull request to add @tomekTieto! 🎉
aaltat commentedon Oct 1, 2021
This is true, we do not do conversion, we just take arguments as they are, which in this case is plain strings and feed them forward. When we run keyword, we did expect that Robot Framework has done argument conversion and do not check any of the arguments.
The problem is that if there is keyword which is not keyword from this library, we do know the arguments types and therefore we can not do argument conversion. But it might be possible to do argument conversion for keywords which are from this library.
So there is two fixes:
aaltat commentedon Oct 1, 2021
Reading the code also reveals nice bug in our code
When
Take Screenshotis run, code putsfilenamewhatever was given as first argument. That is also wrong.aaltat commentedon Oct 4, 2021
Even with that bug fixed we need to conversion for the arguments internally. Library relies on RF to the conversion when methods are run as keywords but for this usage case we need to do the conversion internally. Will look some RF api to do it, because argument conversion is pretty complex problem.
aaltat commentedon Oct 4, 2021
Had discussion with Pekka on Slack and this should work nicely:
aaltat commentedon Oct 6, 2021
Now
Register Keyword To Run On Failurewill return an object which contains keywords name and args. Instead of the old keyword name. That is BICWIC change.aaltat commentedon Oct 7, 2021
@tomekTieto this is now fixed in main branch in the repository. Could you give it a try and see does it work like you expected?
tomekPawlak commentedon Oct 15, 2021
Hello @aaltat now I'm experiencing an issue:
[ WARN ] Keyword 'Take Screenshot ('fullPage', True)' could not be run on failure: 'tuple' object has no attribute 'upper'same with all possible arguments.
Tested on my local Windows environment and on browser-docker image.
aaltat commentedon Oct 15, 2021
Could you run test with --loglevel trace set from command line and show full stack trace.
tomekPawlak commentedon Oct 15, 2021
Added even a debug log but nothing special there regarding issue
debug-20211015-124501.log
aaltat commentedon Oct 15, 2021
Ah, now I see. You have used named argument syntax,
key=valueand looks like we have a bug there.aaltat commentedon Oct 15, 2021
As a workaround doing something like this should work
https://github.com/MarketSquare/robotframework-browser/blob/main/atest/test/01_Browser_Management/run_on_failure.robot#L47
But there definitely is a bug.
tomekPawlak commentedon Oct 15, 2021
Yes, using positional arguments instead of named arguments is working fine
aaltat commentedon Oct 15, 2021
Lets move the discussion in #1396