generated from Nosferican/PkgTPL.jl
/
07_Get_Element_Rect.jl
27 lines (26 loc) · 1.22 KB
/
07_Get_Element_Rect.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Command: Get Element Rect
"""
rect(element::Element)::NamedTuple{(:width, :height, :x, :y),NTuple{4,Int64}}
The Get Element Rect command returns the dimensions and coordinates of the given web element.
The returned value is a dictionary with the following members:
- x: X axis position of the top-left corner of the web element relative to the current browsing context’s document element in CSS pixels.
- y: Y axis position of the top-left corner of the web element relative to the current browsing context’s document element in CSS pixels.
- height: Height of the web element’s bounding rectangle in CSS pixels.
- width: Width of the web element’s bounding rectangle in CSS pixels.
"""
function rect(element::Element)::NamedTuple{(:width, :height, :x, :y),NTuple{4,Int64}}
@unpack addr, id = element.session
element_id = element.id
response = HTTP.get(
"$addr/session/$id/element/$element_id/rect",
[("Content-Type" => "application/json")],
)
@assert response.status == 200
output = JSON3.read(response.body).value
(
width = output.width,
height = output.height,
x = output.x,
y = output.y,
)::NamedTuple{(:width, :height, :x, :y),NTuple{4,Int64}}
end