-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full page screenshot #312
base: master
Are you sure you want to change the base?
Full page screenshot #312
Conversation
With this PR will all screenshots always be full page (i.e. not just the viewport, what is visible, but the whole page)? I do believe however that it would be a great feature to be able to take full page screenshots. But I would put that behind a separate method of BrowserTest. Just like one can check whether an element is visible, or visible somewhere on the page. Additionally there could be a configuration option to switch the default screenshots, e.g. the ones taken on exceptions, between full page and viewport. |
All screenshots would be full page, yes. I considered adding a 'takeFullPageScreenshot' method, but a comment in the Selenium screenshot code (TakeScreenshot.class) said:
So I thought this is already what Selenium is trying to do, but failing to do (at least for me in current Chrome) and this change sort of fixes this. I can move the new code to takeFullPageScreenshot and update the pull request, which will keep things backward compatible. Another option might be to add an optional parameter to determine the screenshot size/type which then defaults to the current behaviour. |
I think a new method |
…parate method. Also updated documentation and script test example.
I also updated a screenshot in the |
Yes those tests are a pain. PRs with more reliable, and instructive examples are welcome... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How big is the extra library added (I try to not let the size of standalone.zip get too much bigger)?
* @param basename filename (below screenshot base directory). | ||
* @return location of screenshot. | ||
*/ | ||
public String takeScreenshot(String basename) { | ||
return takeScreenshotWith( | ||
basename, | ||
name -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name -> | |
name -> this::createScreenshot |
name -> | ||
getSeleniumHelper() | ||
.fullPageScreenshot( | ||
getScreenshotBasename(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the extra getScreenshotBasename
required here and not above?
Furthermore it seems a bit odd that both the basename is supplied to takeScreenshotWith, and all it does is pass it to the function. Seems easier if the caller would just place it inside the lambda (and then pass Supplier instead of function)
* @param maker function for taking the screenshot, should return the screenshot location. | ||
* @return location of screenshot. | ||
*/ | ||
private String takeScreenshotWith(String baseName, Function<String, String> maker) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make protected, so people can override in subclasses, should they want to
String result = null; | ||
byte[] png = null; | ||
|
||
switch (type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this not just be two methods instead of switch on type (or at least make each branch just call a method)
I did the cleanup I requested and pushed to a branch When I tried to run the code I repeatedly got an exception:
|
I have replaced the Selenium screenshot taker with aShot, as Selenium does not seem to be able to take a full page screenshot.