From 06381273ad8bc0da80ae2c3e7f31d255024845f3 Mon Sep 17 00:00:00 2001 From: Taras Kozlovskyi Date: Fri, 27 Feb 2015 16:20:04 +0200 Subject: [PATCH] Added of 'Get Window Position' and 'Set Window Position' --- CHANGES.rst | 4 ++++ .../keywords/_browsermanagement.py | 20 +++++++++++++++++++ test/acceptance/windows.txt | 10 ++++++++++ 3 files changed, 34 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index e22d314c0..3e1f8a964 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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' 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 0e21aaf06..531675069 100644 --- a/test/acceptance/windows.txt +++ b/test/acceptance/windows.txt @@ -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}