diff --git a/CHANGES.rst b/CHANGES.rst index 815e8b0c5..ae1fa2137 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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' diff --git a/src/Selenium2Library/keywords/_browsermanagement.py b/src/Selenium2Library/keywords/_browsermanagement.py index 1b07ac9e1..57b673edf 100644 --- a/src/Selenium2Library/keywords/_browsermanagement.py +++ b/src/Selenium2Library/keywords/_browsermanagement.py @@ -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. diff --git a/test/acceptance/windows.txt b/test/acceptance/windows.txt index 2ee240da8..552d3754d 100644 --- a/test/acceptance/windows.txt +++ b/test/acceptance/windows.txt @@ -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}