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

Should find element with not-integer offset (closes #2080) #2760

Merged
merged 4 commits into from
Aug 30, 2018

Conversation

AlexKamaev
Copy link
Contributor

No description provided.

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit ef5c8b6 have failed. See details:

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot retest

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit ef5c8b6 have failed. See details:

const roundFn = browserUtils.isFirefox ? Math.ceil : Math.round;
const offsetX = this.options.offsetX;
const offsetY = this.options.offsetY;
const screenPointBeforeAction = getAutomationPoint(this.element, offsetX, offsetY, roundFn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need to pass roundFn to the getAutomationPoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAutomationPoint based on hammerhead's getOffsetPosition. Currently the getOffsetPosition is implemented to return rounded X, Y offset of element. When it rounds 50.1px to '50'px it makes document.elementFromPoint work wrong in FF, but if works perfectly fine in Chrome/IE. So we need to round 50.1 not to 50 but to 51 only in FF.
The test checks that that even with different positions we click in correct position of element (0, 0) in all browsers.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use these different round functions for getAutomationPoint only in this place? What about drag or move automation and etc.?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to research, currently I'm not working on this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we do not need to use different round functions in other places. The issue occurs because of combination getAutomationPoint and elementFromPoint. There is no such a combination in other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked one more time, and I've found that actually we can get error in FF in other places (i.e. drag and hover). So I'd better to modify getAutomationPoint function.
Moreover, I've discovered that new drag test does not work in IE. The reason is unclear but it does not connected to this issue. I think we need to create the separate issue for this case. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, let's create separate issue for IE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reasearched the issue in IE, and I've found that in case of drag (or hover) we can't guarantee that target element in { x, y } will be an expected element. For example in the drag automation, for calculating the target { x, y } position we get source element coordinates with the getAutomationPoint method and then add { offsetX, offsetY } integer values. Depending on source element position it can be rounded down or up, i.e. 3.1 => 3 but 3.5 => 4, so target coors can differ. Besides, target element can also have fractional position, so we can not predict how we need to round the coordinates.
I've decided to fix it only in FF, because this scenario is common and very easy to reproduce.

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 7e8f42e have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 26beaa6 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 6456c3c have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 6456c3c have passed. See details:

@AlexKamaev AlexKamaev changed the title [WIP]Should find element with not-integer offset (closes #2080) Should find element with not-integer offset (closes #2080) Aug 28, 2018
@AlexKamaev
Copy link
Contributor Author

please review

<div id="parent">
<div id="child1" class="child">
<div id="leaf1" class="leaf"></div>
<div id="drag"></div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now we can remove this element

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit d0fa5c6 have passed. See details:

@AlexKamaev
Copy link
Contributor Author

@churkin FPR

var top = element === document.documentElement ? 0 : elementOffset.top;
const roundFn = browserUtils.isFirefox ? Math.ceil : Math.round;
const elementOffset = positionUtils.getOffsetPosition(element, roundFn);
const left = element === document.documentElement ? 0 : elementOffset.left;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little thing:

const isDocumentElement = element === document.documentElement;

But It does not matter.

@AlexKamaev AlexKamaev merged commit 3e0338f into DevExpress:master Aug 30, 2018
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this pull request Dec 18, 2019
…evExpress#2760)

* Should find element with not-integer offset (closes DevExpress#2080)

* more tests

* remove tests

* remove excess element
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants