Fix #1459: Add Capture Full Page Screenshot by kumy · Pull Request #1762 · robotframework/SeleniumLibrary

@kumy

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 kumy mentioned this pull request

Dec 12, 2021

@kumy

Anyone able to review please?

@aaltat

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.

@kumy

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

@emanlove

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?).

@kumy

So if I understand correctly,

  1. remove the new keyword, we then have to user Register Keyword To Run On Failure, should be quite easy.
  2. 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

@emanlove

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.

@kumy

@kumy

@kumy

@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 Screenshot

Thanks for your review

@kumy

Hi, is there anything else I can do? Thanks

@aaltat

@emanlove

Not sure why the CI tests didn't run. Initial quick review doesn't seem to indicate anything. Doing some more in depth looking ..

@hrnaltnts

Hello
Currently, do have any solution to take full page screenshots using Selenium Library?