SeleniumLibrary
SeleniumLibrary copied to clipboard
Fix #1459: Add Capture Full Page Screenshot
Please find PR to allow capture full page screenshot. It use the functions linked per @aaltat in https://github.com/robotframework/SeleniumLibrary/issues/1459#issuecomment-535932114
This add a new keyword Capture Full Page Screenshot
. It also add a boolean parameter full_screen
to Capture Page Screenshot
.
Anyone able to review please?
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? :thinking:
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_screen
parameter 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 :smile:
- 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 Screenshot
Thanks for your review
Hi, is there anything else I can do? Thanks
@emanlove why the CI did not run?
@kumy tests are needed.
Not sure why the CI tests didn't run. Initial quick review doesn't seem to indicate anything. Doing some more in depth looking ..
Hello Currently, do have any solution to take full page screenshots using Selenium Library?