Describe the bug
The method BrowserHandler.move_screenshots_to_folder will currently move any file of type ".png" into the target folder. This means that, if you have many threads concurrently saving .png files into the screenshots directory, there is a possibility that one thread may move screenshots created by the other thread into the wrong target folder.
To Reproduce
(Note: due to the nature of this issue, it is hard to reproduce.) Steps to reproduce the behavior:
- In one thread, call
take_screenshot to save a .png file to the /screenshots folder.
- In another parallel thread, call
take_screenshot again to save another .png file to the /screenshots folder.
- In the first thread, now call
move_screenshots_to_folder to move the .png file to the given target folder. Both the .png files created in steps 1 and 2 will be moved to the target folder, not just the screenshot taken by this thread.
- In the second thread, now also call
move_screenshots_to_folder. There will be no screenshots to move.
Expected behavior
Without breaking the existing behaviour, we need to provide:
- Some mechanism for getting the name of any files saved by a call to the
BrowserHandler.take_screenshot method.
- A mechanism for providing an (optional) list of file names to
BrowserHandler.move_screenshots_to_folder which will be used to only move files matching those file names as opposed to any file of type ".png".
Additional context
This problem arose for our team because we run our acceptance tests parallelised per feature file in concurrently running docker containers, but volume mounted with a shared /screenshots directory on the running agent. We initially solved this problem by adding a fork of these two static methods in our own repo, but we want to include a bug fix for the underlying issue in the library so that we don't have to keep maintaining a duplicate of this functionality.
Describe the bug
The method
BrowserHandler.move_screenshots_to_folderwill currently move any file of type ".png" into the target folder. This means that, if you have many threads concurrently saving .png files into the screenshots directory, there is a possibility that one thread may move screenshots created by the other thread into the wrong target folder.To Reproduce
(Note: due to the nature of this issue, it is hard to reproduce.) Steps to reproduce the behavior:
take_screenshotto save a .png file to the /screenshots folder.take_screenshotagain to save another .png file to the /screenshots folder.move_screenshots_to_folderto move the .png file to the given target folder. Both the .png files created in steps 1 and 2 will be moved to the target folder, not just the screenshot taken by this thread.move_screenshots_to_folder. There will be no screenshots to move.Expected behavior
Without breaking the existing behaviour, we need to provide:
BrowserHandler.take_screenshotmethod.BrowserHandler.move_screenshots_to_folderwhich will be used to only move files matching those file names as opposed to any file of type ".png".Additional context
This problem arose for our team because we run our acceptance tests parallelised per feature file in concurrently running docker containers, but volume mounted with a shared /screenshots directory on the running agent. We initially solved this problem by adding a fork of these two static methods in our own repo, but we want to include a bug fix for the underlying issue in the library so that we don't have to keep maintaining a duplicate of this functionality.