Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Release Notes
travis config for situations where testing is failing on travis for an unknown reason.
[zephraph]

- Added 'Get Window Position' and 'Set Window Position' keywords matching the
Selenium functionality.
[ktarasz]

1.6
---
- Added examples to 'Execute Javascript' and 'Execute Async Javascript'
Expand Down
20 changes: 20 additions & 0 deletions src/Selenium2Library/keywords/_browsermanagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,26 @@ def set_window_size(self, width, height):
"""
return self._current_browser().set_window_size(width, height)

def get_window_position(self):
"""Returns current window position as `x` then `y`.

Example:
| ${x} | ${y}= | Get Window Position |
"""
position = self._current_browser().get_window_position()
return position['x'], position['y']

def set_window_position(self, x, y):
"""Sets the position `x` and `y` of the current window to the specified values.

Example:
| Set Window Size | ${1000} | ${0} |
| ${x} | ${y}= | Get Window Position |
| Should Be Equal | ${x} | ${1000} |
| Should Be Equal | ${y} | ${0} |
"""
return self._current_browser().set_window_position(x, y)

def select_frame(self, locator):
"""Sets frame identified by `locator` as current frame.

Expand Down
10 changes: 10 additions & 0 deletions test/acceptance/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ Get and Set Window Size
Should Be Equal ${returned_width} ${win_width}
Should Be Equal ${returned_height} ${win_height}


Get and Set Window Position
${position_x}= Set Variable ${100}
${position_y}= Set Variable ${100}
Set Window Position ${position_x} ${position_y}
${returned_x} ${returned_y}= Get Window Position
Should Be Equal ${position_x} ${returned_x}
Should Be Equal ${position_y} ${returned_y}


*Keywords*
Open Popup Window, Select It And Verify
[Arguments] ${window_id}
Expand Down