SeleniumLibrary icon indicating copy to clipboard operation
SeleniumLibrary copied to clipboard

Fix #1459: Add Capture Full Page Screenshot

Open kumy opened this issue 3 years ago • 11 comments

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.

kumy avatar Dec 12 '21 21:12 kumy

Anyone able to review please?

kumy avatar Jan 29 '22 10:01 kumy

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.

aaltat avatar Jan 29 '22 11:01 aaltat

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

kumy avatar Jan 29 '22 11:01 kumy

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

emanlove avatar Jan 29 '22 16:01 emanlove

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

kumy avatar Jan 29 '22 19:01 kumy

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 avatar Feb 01 '22 18:02 emanlove

@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

kumy avatar Apr 02 '22 11:04 kumy

Hi, is there anything else I can do? Thanks

kumy avatar Jun 26 '22 15:06 kumy

@emanlove why the CI did not run?

@kumy tests are needed.

aaltat avatar Jun 26 '22 19:06 aaltat

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

emanlove avatar Jun 26 '22 23:06 emanlove

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

hrnaltnts avatar Jun 29 '23 12:06 hrnaltnts