Fix Save Selenium Screenshot when a screenshot directory is configured - #517
Open
eastagiletracker wants to merge 1 commit into
Open
Conversation
Save Selenium Screenshot only captured when screenshot_root_directory was EMBED or was not a string. Setting it to a directory path - either when importing GUILibrary or via Set Screenshot Directory - fell through both branches, so the keyword returned None and no screenshot was taken. As this is GUILibrary's default run_on_failure handler, those suites lost their failure screenshots silently. Only intercept when the configured directory is an embed style value (EMBED or BASE64) and otherwise always capture with the unique generated filename, letting SeleniumLibrary resolve the directory. Unit tests added for the directory, BASE64, lowercase embed and unset cases.
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proposes a fix for
Save Selenium Screenshot, which silently takes no screenshot at all when a screenshot directory is configured. We include this PR work along with a full history of your repo at https://eastagiletracker.com/projects/271. You can sign in with your GitHub ID to claim ownership of the project.The defect
GUILibraryimports withrun_on_failure='Save Selenium Screenshot', and documentsscreenshot_root_directoryas "Path to folder where possible screenshots are created or EMBED". The keyword handles theEMBEDhalf of that sentence but not the other one:When
screenshot_root_directoryis a directory path — set either on import or withSet Screenshot Directory— the outer branch is taken, the inner one is not, and the keyword falls off the end and returnsNonewithout ever callingcapture_page_screenshot. Nothing raises, so a suite configured that way loses every failure screenshot without a word in the log. The existing unit tests do not catch it because they exercise onlyEMBEDand aMockroot directory, both of which take the other path.Reproducing it on master
At
c509a1c(current master), against a real headless Chrome withscreenshot_root_directorypointed at an empty directory:The same script against this branch:
The change
save_selenium_screenshotnow intercepts only when the configured directory is an embed-style value, and otherwise always captures with the generated unique filename, leaving SeleniumLibrary to resolve the configured directory (which it already does in_get_screenshot_path).EMBEDbehaves exactly as before.BASE64— SeleniumLibrary's other embed-style directory value since 6.8, and the repo pins 6.9.0 — is handled alongsideEMBEDrather than being written into a directory literally namedBASE64. The public keyword name, its signature and its return value for every case that worked before are unchanged, so existing suites are unaffected.Removing the nested
ifalso retires the one call torobot.utils.is_string, which is deprecated for removal in Robot Framework 9.0 and was the onlyDeprecationWarningin your unit test output;isinstance(item, str)is that helper's own implementation.Verification
pytest --cov-config=.coveragerc --cov=srcon master before the change: 212 passed, 2 warnings, 100% coverage. On this branch: 217 passed, 0 warnings, 100% coverage — no new failures. Five unit tests are added intest/GUI/test_gui.pycovering the configured-directory case, filename uniqueness across calls,BASE64, lowercaseembed, and the unset default. Three of them fail against the unmodifiedGUILibrary.pyand pass with it:The two passing ones are deliberate controls:
EMBEDand the unset directory already worked, and still do.How this was managed
This work was tracked as https://eastagiletracker.com/projects/271/stories/160635 on a board built from this repository's own issues and pull requests (491 stories, 13 labels imported), which you can browse at https://eastagiletracker.com/projects/271.
If you'd rather not receive contributions like this, reply
no-more-prson this pull request and we won't open any further ones on your repositories.Lawrence W. Sinclair
CEO / East Agile
linkedin.com/in/lwsinclair/
eastagile.com