Closed Bug 1036365 Opened 6 years ago Closed 6 years ago

Implement webelement#getElementRect to marionette

Categories

(Testing :: Marionette, defect)

x86
macOS
defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED
mozilla33

People

(Reporter: automatedtester, Assigned: automatedtester)

References

()

Details

(Keywords: pi-marionette-spec)

Attachments

(1 file, 3 obsolete files)

This will simplify getting the location and the size into 1 call
Blocks: 1036498
Assignee: nobody → dburns
Status: NEW → ASSIGNED
Attachment #8453159 - Attachment is obsolete: true
Attachment #8453159 - Flags: review?(mdas)
Comment on attachment 8453696 [details] [diff] [review]
Implement element.rect to marionette for getting element size and location

Review of attachment 8453696 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, just unsure about scrollbars in chrome

::: testing/marionette/client/marionette/marionette.py
@@ +169,5 @@
> +
> +            * x and y represent the top left coordinates of the WebElement relative to top left corner of the document.
> +            * height and the width will contain the height and the width of the DOMRect of the WebElement.
> +
> +            The point (0, 0) refers to the top left corner of the document.

This line doesn't seem necessary, I think it's implied from the description of x and y. If you want to include it, you can add it in that description.

::: testing/marionette/marionette-server.js
@@ +1887,5 @@
> +            aRequest.parameters.id, this.getCurrentWindow());
> +        let clientRect = el.getBoundingClientRect();
> +        this.sendResponse({x: clientRect.x, y: clientRect.y,
> +                           width: clientRect.width, height: clientRect.height},
> +                          command_id);

is it possible to scroll in a chrome window/frame? If so, we should add the pageX/pageY offset to the returned x,y coordinates
Attachment #8453696 - Attachment is obsolete: true
Attachment #8453696 - Flags: review?(mdas)
updated patch after comments
Attachment #8454938 - Attachment is obsolete: true
Attachment #8454938 - Flags: review?(mdas)
This time with 100% more update
Attachment #8454939 - Flags: review?(mdas) → review+
https://hg.mozilla.org/mozilla-central/rev/fea261bd38e8
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
There is no way in Marionette to get the element's location relative to the screen instead of the document, right?
Martijn, use executeScript
(In reply to Martijn Wargers [:mwargers] (QA) from comment #11)
> There is no way in Marionette to get the element's location relative to the
> screen instead of the document, right?

The correct approach would be to follow the algorithm outlined here:

https://w3c.github.io/webdriver/webdriver-spec.html#dfn-calculate-the-absolute-position

And add window.screenX and window.screenY to the result.

Practically this means you can use getElementRect, look at the x and y properties and add these numbers to screenX and screenY.
You need to log in before you can comment on or make changes to this bug.