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
Make the default file name for 'Capture Page Screenshot' more unique #268
Capture Page Screenshot takes a filename argument so you can have any naming scheme you want. To control the filename when there is a failure you can do something similar to the following:
Register Keyword To Run On Failure Save Selenium Screenshot
*** Keywords ***
Save Selenium Screenshot
${screenshot_index}= Get Variable Value ${screenshot_index} ${0}
Set Global Variable ${screenshot_index} ${screenshot_index.__add__(1)}
${time}= Evaluate str(time.time()) time
Capture Page Screenshot selenium-screenshot-${time}-${screenshot_index}.png
The reasoning behind still using an index is that time.time is not guaranteed to be more granular than a second (on Windows it is). Two screenshots within a second is possible and we do not want one to overwrite the other.
If you are requesting that the default filename be more unique, than please say so.
@sdarshanam I think this would be a good idea. I believe a lot of people are re-inventing the wheel out there.
Besides datetime, another option to consider would be using a UUID, like Selenium does for a session ID.
The only concern would be breaking existing tests due to the path being too long.
Do we really need 'selenium-screenshot-' as part of the file name? we already know its a png (screenshot) and its from selenium, moreover its a default file name, so why not just have UUID as file name?
Activity
ombre42 commentedon Jan 24, 2014
Capture Page Screenshot takes a filename argument so you can have any naming scheme you want. To control the filename when there is a failure you can do something similar to the following:
The reasoning behind still using an index is that time.time is not guaranteed to be more granular than a second (on Windows it is). Two screenshots within a second is possible and we do not want one to overwrite the other.
If you are requesting that the default filename be more unique, than please say so.
sdarshanam commentedon Jan 25, 2014
Thanks Kevin. I will try this out. Nevertheless, can the default file name made more unique.
ombre42 commentedon Jan 27, 2014
@sdarshanam I think this would be a good idea. I believe a lot of people are re-inventing the wheel out there.
Besides datetime, another option to consider would be using a UUID, like Selenium does for a session ID.
The only concern would be breaking existing tests due to the path being too long.
sdarshanam commentedon Jan 29, 2014
Do we really need 'selenium-screenshot-' as part of the file name? we already know its a png (screenshot) and its from selenium, moreover its a default file name, so why not just have UUID as file name?
mulmschneider commentedon Jul 30, 2014
I've created a pull request for more unique screenshot names, but a quick workaround is to just redefine the 'Run on Failure' keyword:
aaltat commentedon May 23, 2016
The current code in master, which is not yet released allows more configuration on the file name. Therefore closing the issue.
If you feel that this issue should not have been closed, send an update and we will re-open the issue.