Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Add offset support to click and hover#57

Merged
ernestas-zekas merged 4 commits intomasterfrom
add-offset-support-to-click-and-hover
Oct 13, 2020
Merged

Add offset support to click and hover#57
ernestas-zekas merged 4 commits intomasterfrom
add-offset-support-to-click-and-hover

Conversation

@ernestas-zekas
Copy link
Collaborator

  • Added new method getCoordinates in Elements class;
  • Refactored clicks and hover methods to use new method getCoordinates;
  • Added new tests to cover changes in framework;
  • Fixed false positive testcase;
  • Added duration parameter to abortRequestsAfterAction method in interceptor class.

- Refactored clicks and hover methods to use new method getCoordinates;
- Adde new tests to cover changes in framework;
- Fixed false postive testcase;
- Added duration parameter to abortRequestsAfterActionmethod in interceptor class.
@vaidasmaciulis vaidasmaciulis linked an issue Sep 25, 2020 that may be closed by this pull request
# Conflicts:
#	example/tests/elementActions.test.js
#	example/tests/interceptor.test.js
const yCoordinate = rect.y + y;
console.log(`Action on page at position x: ${xCoordinate}, y: ${yCoordinate}`);
console.log(`Action on element rectangle at position x: ${x}, y: ${y}`);
return [xCoordinate, yCoordinate];
Copy link
Collaborator

Choose a reason for hiding this comment

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

For readability I suggest returning this as an object, like return { x: xCoordinate, y: yCoordinate };
Then it can be called as coordinates.x, coordinates.y in line 63 and others

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed

}

async click() {
async getCoordinates(xOffset, yOffset, elementHandle) {
Copy link
Collaborator

@vaidasmaciulis vaidasmaciulis Sep 28, 2020

Choose a reason for hiding this comment

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

I was thinking how this might be used from test, as it will be public. User might expect to call it as element.getCoordinates() and simply get the coordinates of the element. But for this to work we need waiter inside, and we should not pass elementHandle.
So, this method can have lines inside:

const elementHandle = await this.wait();
await elementHandle.focus();

Then in other methods i.e. click(), these lines can be removed, as only coordinates is required to do the action. And we know element will be already loaded as wait() have already been called in this method.

Copy link
Collaborator

Choose a reason for hiding this comment

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

As this is new public method we need to add separate test for it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed.

}

async abortRequestsDuringAction(action, requestUrlFragment = "") {
async abortRequestsAfterAction(action, requestUrlFragment = "", waitDuration = 500) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a note: this is breaking change, due to rename and next release will need to have major version updated. (We have merged some breaking changes already, so it will be anyways)

@ernestas-zekas ernestas-zekas merged commit 3ff9a32 into master Oct 13, 2020
@ernestas-zekas ernestas-zekas deleted the add-offset-support-to-click-and-hover branch October 13, 2020 10:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add offset support to click() and hover()

4 participants