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):
297297 raise AssertionError ("Could not determine position for '%s'" % (locator ))
298298 return element .location ['x' ]
299299
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+
300310 def get_value (self , locator ):
301311 """Returns the value attribute of element identified by `locator`.
302312
Original file line number Diff line number Diff line change @@ -69,3 +69,14 @@ Get Vertical Position
6969 Should Be True ${pos } > ${0 }
7070 Run Keyword And Expect Error Could not determine position for 'non-existent'
7171 ... 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 3535 < a href ="target/second.html "> < img src ="robot.png " alt ="Image "/> </ a >
3636 < a href ="target/second.html "> Link</ a >
3737 </ div >
38+ < div id ="emptyDiv "> </ div >
3839 < a href ="index.html " target ="_blank "> Target opens in new window</ a >
3940 </ body >
4041</ html >
You can’t perform that action at this time.
0 commit comments