Fix #1459: Add Capture Full Page Screenshot by kumy · Pull Request #1762 · robotframework/SeleniumLibrary
Please find PR to allow capture full page screenshot. It use the functions linked per @aaltat in #1459 (comment)
This add a new keyword Capture Full Page Screenshot. It also add a boolean parameter full_screen to Capture Page Screenshot.
kumy
mentioned this pull request
I am not anymore maintaining this library, ping @emanlove But in my opinion having new keyword is not good idea, just have argument for the existing one is better.
Thanks for your reply. If there is no new keyword, then is there a way to set the argument to full_screen=True on library import? 🤔
I was using it like this:
Library SeleniumLibrary timeout=10 implicit_wait=0 run_on_failure=capture full page screenshot
I agree that an additional separate keyword would not be preferred. One problem I see is adding a parameter to the keyword (Capture Page Screenshot) that itself is a parameter to the run_on_failure library argument. Tatu has mentioned to me that there is code within BrowserLibrary which allows parameters on parameters within library import arguments. This might be better than the alternative of using the Register Keyword To Run On Failure keyword within the script. One question I have there is are we making the library import even more complicated if we do this and have plug-ins?
The other issue is that get_full_page_screenshot_as_base64 is only a method on the Firefox driver and not on any of the others. There should be some code to protect against that. I know there is desire for full page screenshot across browser but think that should be addressed in a different issue (possibly?).
So if I understand correctly,
- remove the new keyword, we then have to user
Register Keyword To Run On Failure, should be quite easy. - protect new
full_screenparameter to be used on other driver than Firefox.
For 2., I've not yet any idea how to do that. Do you have existing code example from which I could learn from? Thanks
One technique would be to use the hasattr function to check and if if the driver object has the get_full_page_screenshot_as_base64 method.
@emanlove Hello, I've finally done the requested changes 😄
- New keyword removed
- Check function presence or fallback to normal mode.
Could be used like:
*** Settings *** Library SeleniumLibrary run_on_failure=Capture Full Page Screenshot # […] # […] *** Keywords *** Capture Full Page Screenshot Capture Page Screenshot full_screen=True
Or by using
Register Keyword To Run On Failure Capture Full Page ScreenshotThanks for your review
Not sure why the CI tests didn't run. Initial quick review doesn't seem to indicate anything. Doing some more in depth looking ..
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