-
Notifications
You must be signed in to change notification settings - Fork 43
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
Fix: Do not complain when endY is bigger than document height #54
base: master
Are you sure you want to change the base?
Conversation
Thanks for your PR.
My intention for this check was to find a test case that fails. Initially I thought that when endY is bigger than the documents height, then we have to use the documentHeight instead to get properly taken screenshots. But I wasn't sure if that 's the right way so I ended up with that error instead 😄 As I can see you just removed that check. Are the screenshots really ok? Regardless of the direction, it would be awesome & necessary to get a simple integration test for this. |
@zinserjan glad to hear that. I totally agree with the integration test for this scenario. As I mentioned I tried to run integration tests using I wonder what was the environment that you ran integration tests on it (in terms of pixel ratio). |
Pixelratio 1. I created some of the screenshots in a VM with Ubuntu, some others with Windows (for the IE cases). When you are testing with a Retina Macbok, tests will fail due to the size (twice as big). |
@zinserjan I managed to run integration tests on Ububunu and all of them are passing. I also added two more integration tests for the new scenario and it works. Can you help on broken tests in Travis/Appveyor please? What's the process of generating reference IE images, I just copied the Linux one. |
Screenshots for IE are generated by IE ;-) But I'm not sure which version it was. Must be IE 9 or IE 10. I just looked over the test page and I didn't found any reason in my browser why this should fail and tried the tests with the old code. And indeed tests passes with the old code cause element height is smaller than documents height. Can you update the test case in a way that it will fail with the original code? I think it should be enough to expand height of the element. |
@zinserjan let's park IE screenshots for now as it's not a big deal. I updated the example so it fails with the original code and passes with the change. The Digging into this problem, I noticed that we don't have the support of scrolling an element instead of the whole page. With the original fix, we can take the screenshot but the screenshot is broken because we move up the whole page instead of a specific element. I think, allowing the user to define an element as scroll target would fix this issue. I'm open to any suggestion to fix this problem. |
Yes, this is right and that's the real issue here. Just disabling the
With broken you mean kind of incomplete, right? Only the visible part of the element is recorded and the rest of the screen is filled with the next element (below the captured/desired element)?
I think it's more complicated. We have to think about two use cases:
element screenshotsThis should be easiest case, cause we could detect if the element is scrollable or inside a scrollable container. I'm not sure right now if we have to check the second condition. document screenshotsThat's the funny part, when we want to consider the following use case:
This is already complicated to handle but we can increase the complexity when you have multiple elements with that behavior (e.g. side by side with different heights). How does the final screenshot look like? I think everyone has a different opinion about that. |
Indeed.
Yes, the visible part will be available in screenshot and rest will be yellow in our case (background color of the page is yellow). This is due to behavour of
I propose to add an scroll option to
Well I don't think we need to mess with the elements. If consumer provides a selector as scroll target, we assume that the element is already scrollable. Am I missing something?
We can keep this small and add support of custom scroll to the element |
@zinserjan I added my proposed solution for the scroll to the PR. |
*/ | ||
let html = options && options.scroll | ||
? document.querySelector('.test-target') | ||
: document.documentElement; |
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.
@zinserjan we can throw an error if selector doesn't match any element in DOM to help for debugging.
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.
IMO the query Selector should be configuration if we are adding a scroll option.
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.
Looks like the forked repo (autopilothq/wdio-screenshot) master branch has fixed this in a later commit. But those changes haven't been merged into the autopilothq:set-scroll-area-bug-fix
branch, where this PR originated from.
I'm not convinced that this will work in all cases. I still think that we need the original virtualScroll on I'll try to create an example. But maybe I'm wrong cause CSS isn't my daily business 😆 |
TBH I can't think of a case in which we need to move to scroll two scrollbars at the same time to take a screenshot of an element, neither this PR is going to fix all possible situations. I updated the new tests, so scroll target is different from the element under the test to show they don't need to be the same element. I would like to think of this PR as a fix and a feature
|
@zinserjan is there any intention to proceed with this PR? |
@zinserjan Hi. Are you still interested in this PR? We need this feature for our project and if it's not going to be merged we have to find another solution for our problem. Thanks |
@mehdivk Sorry for the delay but the new year is very time consuming and I haven't found the time, yet.
Which of the following do you mean exacly?
At the moment I would like to avoid introducing a new option that allows the user to define a custom scroll target until #21 and #48 are resolved. My preference is a automatic scroll element detection, so that the screenshot stitching algorithm remains as a black box for the user. |
hi all. i just got x-reffed here after suffering the following error |
ah, & i should have asked earlier... is there a temp workaround? |
Just chiming in to say that this still exists. I'm also seeing a similar error with endX. |
@@ -23,8 +23,6 @@ export default class BaseStrategy { | |||
throw new Error('startY is out of range'); | |||
} else if (endX > documentWidth) { | |||
throw new Error('endX is out of range'); | |||
} else if (endY > documentHeight) { |
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.
If we are passing options, I would disabling this error should be in the option as well. By removing this, this is breaking expected behavior (though I think most people would be okay with it)
This PR fixes the bug that was reported in this issue zinserjan/wdio-visual-regression-service#14
As I mentioned in that issue, if part of an element stays out of viewport (need scroll to be visible) this plugin throws an error. Unfortunately, there is no documentation in code so I couldn't find what's the initial intention for this check. Anyway, what I've done is to use this module directly against our project and with this check removed from the code,
wdio-screenshot
successfully takes expected screenshot of the element.As side note, I think we can remove the similar check for
endX
as well. Unit tests are passing but integration tests are failing in my end when I runnpm run test:local
due to some pixel ratio.