Skip to content
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

getDocHeight() incorrectly returning viewport height for some applications #66

Closed
roboaks opened this issue Dec 30, 2019 · 6 comments
Closed
Assignees
Labels

Comments

@roboaks
Copy link

roboaks commented Dec 30, 2019

I am using Chrome 79.0.3945.88 (64-bit) and Selenium WebDriver 3.141.59. When I use a public website like Google or Wikipedia the WHOLE_PAGE strategy works fine. I can see the page scrolling and the screenshot reflects that,

Using a proprietary application (Guidewire PolicyCenter, a major insurance system vendor), however, it doesn’t work. I’ve done some tracing and discovered the exact issue: com.assertthat.selenium_shutterbug.utils.web.Browser.getDocHeight() always returns the same value as com.assertthat.selenium_shutterbug.utils.web.Browser.getViewportHeight(). In short, the called JavaScript,

return Math.max(document.body.scrollHeight, document.body.offsetHeight, 
document.documentElement.clientHeight, document.documentElement.scrollHeight, 
document.documentElement.offsetHeight);

Simply returns the viewport height.

I don’t have any knowledge of the web UI framework that PolicyCenter uses and, unfortunately, I can’t provide access to PolicyCenter, as we use it over a VPN.

Have you ever seen anything like this before? Do you have any suggestions?

@glibas
Copy link
Member

glibas commented Dec 30, 2019

Hi @roboaks
Does the web page changes its height when scrolling? I mean if the content loads during the page scroll then worth trying scrolling to the bottom of the page first using JavaScriptExecutor and then trying to take a screenshot as shutterbug is calculating the doc height during first screenshot and so all dynamically loaded content will be ignored.

Hope that helps. Hard to tell not having access to the app, so just an assumption.

@glibas glibas self-assigned this Dec 30, 2019
@roboaks
Copy link
Author

roboaks commented Dec 30, 2019

I added code to scroll to the bottom of the page before taking the screenshot and it doesn't scroll the page. I tried the same code against Wikipedia and it works fine. I even put a breakpoint before the call to ShutterBug and manually scrolled the page but that made no difference. The size of the viewport and document are always calculated as the same.

The fact that a basic call to window.scrollTo doesn't work suggest to me that there is something about this app's UI framework that is non-standard.

Have you encountered other apps that behave this way?

@glibas
Copy link
Member

glibas commented Dec 30, 2019

Another thing might be that the content you are trying to scroll is an iframe and js is executed on the parent page do it's not affecting iframe content

@roboaks
Copy link
Author

roboaks commented Dec 30, 2019

I will investigate that. If that is indeed the case, is there a solution?

@roboaks
Copy link
Author

roboaks commented Dec 30, 2019

Lol: #30 was requested by Richard Morris, who is a colleague. It looks like iframe support is still pending.

@glibas glibas added the bug label Aug 11, 2020
@glibas
Copy link
Member

glibas commented Aug 11, 2020

Implemented in v1.0 e.g

Shutterbug.shootFrame(driver, driver.findElement(By.id("myFrame")),
                Capture.FULL_SCROLL).save();

@glibas glibas closed this as completed Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants