File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
src/Selenium2Library/keywords Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -297,6 +297,16 @@ def get_horizontal_position(self, locator):
297
297
raise AssertionError ("Could not determine position for '%s'" % (locator ))
298
298
return element .location ['x' ]
299
299
300
+ def get_element_size (self , locator ):
301
+ """Returns width and height of element identified by `locator`.
302
+
303
+ The element width and height is returned.
304
+ Fails if a matching element is not found.
305
+ """
306
+ element = self ._element_find (locator , True , True )
307
+
308
+ return element .size ['width' ], element .size ['height' ]
309
+
300
310
def get_value (self , locator ):
301
311
"""Returns the value attribute of element identified by `locator`.
302
312
Original file line number Diff line number Diff line change @@ -69,3 +69,14 @@ Get Vertical Position
69
69
Should Be True ${pos } > ${0 }
70
70
Run Keyword And Expect Error Could not determine position for 'non-existent'
71
71
... Get Horizontal Position non-existent
72
+
73
+
74
+ Get Element Size
75
+ ${width } ${height } = Get Element Size link=Link
76
+ Should be True ${height } > ${0 }
77
+ Should be True ${width } > ${0 }
78
+ Run Keyword And Expect Error ValueError: Element locator 'non-existent' did not match any elements. Get Element Size non-existent
79
+
80
+ Get Empty Element Size
81
+ ${width } ${height } = Get Element Size id=emptyDiv
82
+ Should be True ${height } == 0
Original file line number Diff line number Diff line change 35
35
< a href ="target/second.html "> < img src ="robot.png " alt ="Image "/> </ a >
36
36
< a href ="target/second.html "> Link</ a >
37
37
</ div >
38
+ < div id ="emptyDiv "> </ div >
38
39
< a href ="index.html " target ="_blank "> Target opens in new window</ a >
39
40
</ body >
40
41
</ html >
You can’t perform that action at this time.
0 commit comments