Skip to content

Commit

Permalink
Added of 'Get Window Position' and 'Set Window Position'
Browse files Browse the repository at this point in the history
  • Loading branch information
ktarasz committed Feb 27, 2015
1 parent c0ed09a commit 0638127
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Release Notes
- Added new locator strategy, scLocator, for finding SmartClient and SmartGWT elements.
[IlfirinPL]

- 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 @@ -40,6 +40,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

0 comments on commit 0638127

Please sign in to comment.