From 9a80a3c3c918466e17f17478f46dacb23d70cd47 Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 22 May 2015 21:47:44 +0800 Subject: [PATCH 01/24] add code changes --- .../locators/windowmanager.py | 47 ++++++++++++++----- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/src/Selenium2Library/locators/windowmanager.py b/src/Selenium2Library/locators/windowmanager.py index 5740d38a5..97f48f74c 100644 --- a/src/Selenium2Library/locators/windowmanager.py +++ b/src/Selenium2Library/locators/windowmanager.py @@ -24,7 +24,14 @@ def get_window_titles(self, browser): def select(self, browser, locator): assert browser is not None - + if isinstance(locator, list): + self._select_by_excludes(browser, locator) + return + if locator.lower() == "self" or locator.lower() == "current": + return + if locator.lower() == "new" or locator.lower() == "popup": + self._select_by_last_index(browser) + return (prefix, criteria) = self._parse_locator(locator) strategy = self._strategies.get(prefix) if strategy is None: @@ -53,21 +60,35 @@ def _select_by_url(self, browser, criteria): def _select_by_default(self, browser, criteria): if criteria is None or len(criteria) == 0 or criteria.lower() == "null": - browser.switch_to_window('') + browser.switch_to_window(browser.get_window_handles()[0]) return - - try: - self._select_by_name(browser, criteria) - return - except ValueError: pass - + for handle in browser.get_window_handles(): + browser.switch_to_window(handle) + if criteria == handle: + return + for item in browser.get_current_window_info()[2:4]: + if item.strip().lower() == criteria.lower(): + return + raise ValueError("Unable to locate window with handle or name or title or URL '" + criteria + "'") + + def _select_by_last_index(self, browser): + handles = browser.get_window_handles() try: - self._select_by_title(browser, criteria) - return - except ValueError: pass - - raise ValueError("Unable to locate window with name or title '" + criteria + "'") + if handles[-1] == browser.get_current_window_handle(): + raise AssertionError("Unable to get new window from last index. Please use '@{ex}= | List Windows' + new window trigger + 'Select Window | ${ex}'") + except IndexError: + raise AssertionError("No window found") + except NoSuchWindowException: + raise AssertionError("Currently no focus window. where are you making a popup window?") + browser.switch_to_window(handles[-1]) + def _select_by_excludes(self, browser, excludes): + for handle in browser.get_window_handles(): + if handle not in excludes: + browser.switch_to_window(handle) + return + raise ValueError("Unable to locate new window") + # Private def _parse_locator(self, locator): From c2089a40b494b2534d8217a2cbd2bab50b4d614b Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 22 May 2015 21:53:31 +0800 Subject: [PATCH 02/24] add code changes --- .../keywords/_browsermanagement.py | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/Selenium2Library/keywords/_browsermanagement.py b/src/Selenium2Library/keywords/_browsermanagement.py index 57b673edf..f53ce76cf 100644 --- a/src/Selenium2Library/keywords/_browsermanagement.py +++ b/src/Selenium2Library/keywords/_browsermanagement.py @@ -289,8 +289,11 @@ def select_frame(self, locator): self._current_browser().switch_to_frame(element) def select_window(self, locator=None): - """Selects the window found with `locator` as the context of actions. - + """Selects the window matching locator and return previous window handle. + + locator: any of name, title, url, window handle, excluded handle's list, or special words. + return: either current window handle before selecting, or None if no current window. + If the window is found, all subsequent commands use that window, until this keyword is used again. If the window is not found, this keyword fails. @@ -299,7 +302,11 @@ def select_window(self, locator=None): javascript name of the window. If multiple windows with same identifier are found, the first one is selected. - Special locator `main` (default) can be used to select the main window. + There are some special locators for searching target window: + string 'main' (default): select the main window; + string 'self': only return current window handle; + string 'new': select the last-indexed window assuming it is the newest opened window + window list: select the first window not in given list (See 'List Windows' to get the list) It is also possible to specify the approach Selenium2Library should take to find a window by specifying a locator strategy: @@ -315,7 +322,23 @@ def select_window(self, locator=None): | Title Should Be | Popup Title | | Select Window | | | # Chooses the main window again | """ - self._window_manager.select(self._current_browser(), locator) + try: + return self._current_browser().get_current_window_handle() + except NoSuchWindowException: + pass + finally: + self._window_manager.select(self._current_browser(), locator) + + def list_windows(self): + """Return all current window handles as a list""" + return self._current_browser().get_window_handles() + + def close_window_and_select(self, locator=None): + """Closes current window and then switch to the window matching given locator. + See 'Select Window' keyword for same locator requirement + """ + self._current_browser().close() + return self.select_window(locator) def unselect_frame(self): """Sets the top frame as the current frame.""" From 60a3c262b4509eb9b520f3aa6fed7f20c46b6dd4 Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 22 May 2015 21:58:09 +0800 Subject: [PATCH 03/24] Update CHANGES.rst --- CHANGES.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 12faafcce..7fb9adf3d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,14 @@ Release Notes 1.7 (unreleased) ---------------- +- Added 'Close Window And Select' to simplify 'Close Window' + 'Select Window'. + Added 'List Windows' to return a list of all current handles. + Enhanced 'Select Window' to select new window by excluding a list of window handles + (the strict way), or by special locator 'new' (the simplified but less strict way) + Enhanced 'Select Window' to accept window handle as locator, and special locator + 'self' to return current window handle. + [divfor] + - Fixed ‘NoSuchWindowException' issue. Running keyword 'Select Window' after 'Close Window' will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same issue for keywords 'Get Window Ids', 'Get Window Titles' and 'Get Window Names'. From d51327c6b1d2105b8e0398d77f0daffe08fd7a6e Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 22 May 2015 22:12:52 +0800 Subject: [PATCH 04/24] Update CHANGES.rst --- CHANGES.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 7fb9adf3d..ea70204eb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,12 +3,11 @@ Release Notes 1.7 (unreleased) ---------------- -- Added 'Close Window And Select' to simplify 'Close Window' + 'Select Window'. - Added 'List Windows' to return a list of all current handles. - Enhanced 'Select Window' to select new window by excluding a list of window handles - (the strict way), or by special locator 'new' (the simplified but less strict way) - Enhanced 'Select Window' to accept window handle as locator, and special locator - 'self' to return current window handle. +- Added keyword 'Close Window And Select' to simplify 'Close Window' + 'Select Window'. +- Added keyword 'List Windows' to return a list of all window handles. +- Enhanced 'Select Window' to return window handle, accept window handle as locator, + and select new window by excluding a list of window handles (the strict way), or + by special locator 'new' (the simplified but less strict way) [divfor] - Fixed ‘NoSuchWindowException' issue. Running keyword 'Select Window' after 'Close Window' From 67c62b142d9a59717c4938484ff8e4abe49aba30 Mon Sep 17 00:00:00 2001 From: divfor Date: Sat, 23 May 2015 21:00:37 +0800 Subject: [PATCH 05/24] add test cases for enhancing select window --- test/acceptance/windows.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/acceptance/windows.txt b/test/acceptance/windows.txt index fcee45955..d6977c965 100644 --- a/test/acceptance/windows.txt +++ b/test/acceptance/windows.txt @@ -62,6 +62,39 @@ Get Window Titles After Close Window Close Window ${titles}= Get Window Titles +Select Window By Handle + Cannot Be Executed in IE + Click Link my popup + ${parent}= Select Window Original + Title Should Be Original + ${child}= Select Window ${parent} + Title Should Be Click link to show a popup window + Select Window ${child} + Close Window + ${FromWindow}= Select Window ${parent} + Title Should Be Click link to show a popup window + Should Be True ${FromWindow} == None + +Select Popup Window By Excluded List + Cannot Be Executed in IE + @{excluded_handle_list}= List Windows + Click Link my popup + ${parent}= Select Window ${excluded_handle_list} + Title Should Be Original + Close Window + Select Window ${parent} + Title Should Be Click link to show a popup window + +Select Window By Special Locator + Cannot Be Executed in IE + ${start}= Select Window self + Click Link my popup + ${parent}= Select Window new + Title Should Be Original + Should Be True '${start}' == '${parent}' + Close Window And Select main + Title Should Be Click link to show a popup window + *Keywords* Open Popup Window, Select It And Verify [Arguments] ${window_id} From aeeacfa5c6cf506d89360e320359212314bdd195 Mon Sep 17 00:00:00 2001 From: divfor Date: Sat, 23 May 2015 21:54:05 +0800 Subject: [PATCH 06/24] minor fix --- src/Selenium2Library/keywords/_browsermanagement.py | 1 + src/Selenium2Library/locators/windowmanager.py | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Selenium2Library/keywords/_browsermanagement.py b/src/Selenium2Library/keywords/_browsermanagement.py index f53ce76cf..aac427bd0 100644 --- a/src/Selenium2Library/keywords/_browsermanagement.py +++ b/src/Selenium2Library/keywords/_browsermanagement.py @@ -6,6 +6,7 @@ from Selenium2Library.utils import BrowserCache from Selenium2Library.locators import WindowManager from keywordgroup import KeywordGroup +from selenium.common.exceptions import NoSuchWindowException ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) FIREFOX_PROFILE_DIR = os.path.join(ROOT_DIR, 'resources', 'firefoxprofile') diff --git a/src/Selenium2Library/locators/windowmanager.py b/src/Selenium2Library/locators/windowmanager.py index 97f48f74c..75ca8954a 100644 --- a/src/Selenium2Library/locators/windowmanager.py +++ b/src/Selenium2Library/locators/windowmanager.py @@ -27,11 +27,12 @@ def select(self, browser, locator): if isinstance(locator, list): self._select_by_excludes(browser, locator) return - if locator.lower() == "self" or locator.lower() == "current": - return - if locator.lower() == "new" or locator.lower() == "popup": - self._select_by_last_index(browser) - return + if locator is not None: + if locator.lower() == "self" or locator.lower() == "current": + return + if locator.lower() == "new" or locator.lower() == "popup": + self._select_by_last_index(browser) + return (prefix, criteria) = self._parse_locator(locator) strategy = self._strategies.get(prefix) if strategy is None: From b66a01b90bcbd5058cb8c7f241a591f9a36b81c2 Mon Sep 17 00:00:00 2001 From: divfor Date: Sun, 24 May 2015 08:52:43 +0800 Subject: [PATCH 07/24] update changelog --- CHANGES.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index ea70204eb..d64118d43 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,10 +3,9 @@ Release Notes 1.7 (unreleased) ---------------- -- Added keyword 'Close Window And Select' to simplify 'Close Window' + 'Select Window'. - Added keyword 'List Windows' to return a list of all window handles. -- Enhanced 'Select Window' to return window handle, accept window handle as locator, - and select new window by excluding a list of window handles (the strict way), or +- Enabled 'Select Window' to return window handle as well as accept it as locator, and + select new popup window by excluding previous window handles (the strict way) or by special locator 'new' (the simplified but less strict way) [divfor] From f51c451081312d4df18d768dc7c278f8237059be Mon Sep 17 00:00:00 2001 From: divfor Date: Sun, 24 May 2015 08:54:13 +0800 Subject: [PATCH 08/24] remove close window and select --- src/Selenium2Library/keywords/_browsermanagement.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Selenium2Library/keywords/_browsermanagement.py b/src/Selenium2Library/keywords/_browsermanagement.py index aac427bd0..e048d4431 100644 --- a/src/Selenium2Library/keywords/_browsermanagement.py +++ b/src/Selenium2Library/keywords/_browsermanagement.py @@ -334,13 +334,6 @@ def list_windows(self): """Return all current window handles as a list""" return self._current_browser().get_window_handles() - def close_window_and_select(self, locator=None): - """Closes current window and then switch to the window matching given locator. - See 'Select Window' keyword for same locator requirement - """ - self._current_browser().close() - return self.select_window(locator) - def unselect_frame(self): """Sets the top frame as the current frame.""" self._current_browser().switch_to_default_content() From 589731169738660813430122694a28d736ffc626 Mon Sep 17 00:00:00 2001 From: divfor Date: Sun, 24 May 2015 09:00:15 +0800 Subject: [PATCH 09/24] update test cases --- test/acceptance/windows.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/acceptance/windows.txt b/test/acceptance/windows.txt index d6977c965..d76a8e8b5 100644 --- a/test/acceptance/windows.txt +++ b/test/acceptance/windows.txt @@ -92,7 +92,8 @@ Select Window By Special Locator ${parent}= Select Window new Title Should Be Original Should Be True '${start}' == '${parent}' - Close Window And Select main + Close Window + Select Window main Title Should Be Click link to show a popup window *Keywords* From 5cf78a365555ffaeef9d276d16ce4ea286e2a240 Mon Sep 17 00:00:00 2001 From: divfor Date: Sun, 24 May 2015 09:12:33 +0800 Subject: [PATCH 10/24] minor fix - skip None locator --- src/Selenium2Library/locators/windowmanager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Selenium2Library/locators/windowmanager.py b/src/Selenium2Library/locators/windowmanager.py index 75ca8954a..6159542f9 100644 --- a/src/Selenium2Library/locators/windowmanager.py +++ b/src/Selenium2Library/locators/windowmanager.py @@ -24,10 +24,10 @@ def get_window_titles(self, browser): def select(self, browser, locator): assert browser is not None - if isinstance(locator, list): - self._select_by_excludes(browser, locator) - return if locator is not None: + if isinstance(locator, list): + self._select_by_excludes(browser, locator) + return if locator.lower() == "self" or locator.lower() == "current": return if locator.lower() == "new" or locator.lower() == "popup": From 7f03d4af73bb16feff410e6b735619e68c7e35cf Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 15:13:14 +0800 Subject: [PATCH 11/24] Update CHANGES.rst --- CHANGES.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index d64118d43..5ba707b7e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,17 +3,22 @@ Release Notes 1.7 (unreleased) ---------------- +- Added new keyword 'Wait Until Page Does Not Contain'. + [deiga] + - Added keyword 'List Windows' to return a list of all window handles. + [divfor] + - Enabled 'Select Window' to return window handle as well as accept it as locator, and select new popup window by excluding previous window handles (the strict way) or - by special locator 'new' (the simplified but less strict way) + by special locator 'new' (the simplified but less strict way). [divfor] - + - Fixed ‘NoSuchWindowException' issue. Running keyword 'Select Window' after 'Close Window' will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same issue for keywords 'Get Window Ids', 'Get Window Titles' and 'Get Window Names'. [divfor] - + - Corrected error message in new keyword 'Wait Until Element Is Not Visible' to reflect element being visible instead of not visible. [joepurdy] @@ -30,6 +35,9 @@ Release Notes - Added new keyword 'Wait Until Page Does Not Contain Element'. [molsky] +- Added new keywords 'Wait Until Element Contains' and 'Wait Until Element Does Not Contain' + [molsky] + - Added new locator strategy, scLocator, for finding SmartClient and SmartGWT elements. [IlfirinPL] From e71c6e93a57dddb085ce425e87e26f53867aa78f Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 17:33:11 +0800 Subject: [PATCH 12/24] Update CHANGES.rst --- CHANGES.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 5ba707b7e..79c17e47e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,8 +3,6 @@ Release Notes 1.7 (unreleased) ---------------- -- Added new keyword 'Wait Until Page Does Not Contain'. - [deiga] - Added keyword 'List Windows' to return a list of all window handles. [divfor] @@ -13,6 +11,9 @@ Release Notes select new popup window by excluding previous window handles (the strict way) or by special locator 'new' (the simplified but less strict way). [divfor] + +- Added new keyword 'Wait Until Page Does Not Contain'. + [deiga] - Fixed ‘NoSuchWindowException' issue. Running keyword 'Select Window' after 'Close Window' will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same From 864cab563654d8cffcaee814f5ba55bb369ddb04 Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 17:37:23 +0800 Subject: [PATCH 13/24] Update CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 79c17e47e..fdd8b5ce9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -19,7 +19,7 @@ Release Notes will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same issue for keywords 'Get Window Ids', 'Get Window Titles' and 'Get Window Names'. [divfor] - + - Corrected error message in new keyword 'Wait Until Element Is Not Visible' to reflect element being visible instead of not visible. [joepurdy] From 66e2766c4b1e64160c28c2903dcd9e1c215e0470 Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 17:51:39 +0800 Subject: [PATCH 14/24] Update CHANGES.rst --- CHANGES.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index fdd8b5ce9..d29339632 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,7 +3,6 @@ Release Notes 1.7 (unreleased) ---------------- - - Added keyword 'List Windows' to return a list of all window handles. [divfor] @@ -11,15 +10,15 @@ Release Notes select new popup window by excluding previous window handles (the strict way) or by special locator 'new' (the simplified but less strict way). [divfor] - + - Added new keyword 'Wait Until Page Does Not Contain'. [deiga] - + - Fixed ‘NoSuchWindowException' issue. Running keyword 'Select Window' after 'Close Window' will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same issue for keywords 'Get Window Ids', 'Get Window Titles' and 'Get Window Names'. [divfor] - + - Corrected error message in new keyword 'Wait Until Element Is Not Visible' to reflect element being visible instead of not visible. [joepurdy] From 1fdd1d8af4a69d0b33d04c0387549f50e2054aa5 Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 17:53:41 +0800 Subject: [PATCH 15/24] Update CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index d29339632..2228051d1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -18,7 +18,7 @@ Release Notes will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same issue for keywords 'Get Window Ids', 'Get Window Titles' and 'Get Window Names'. [divfor] - + - Corrected error message in new keyword 'Wait Until Element Is Not Visible' to reflect element being visible instead of not visible. [joepurdy] From a0d87d5fe64ede1b7be83a14c06f4ea247f6373c Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 17:56:09 +0800 Subject: [PATCH 16/24] Update CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2228051d1..d29339632 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -18,7 +18,7 @@ Release Notes will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same issue for keywords 'Get Window Ids', 'Get Window Titles' and 'Get Window Names'. [divfor] - + - Corrected error message in new keyword 'Wait Until Element Is Not Visible' to reflect element being visible instead of not visible. [joepurdy] From c3cdb5ac118da3a0a4788bca565157edab07309c Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 17:57:33 +0800 Subject: [PATCH 17/24] Update CHANGES.rst --- CHANGES.rst | 241 ---------------------------------------------------- 1 file changed, 241 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index d29339632..8b1378917 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,242 +1 @@ -Release Notes -============= -1.7 (unreleased) ----------------- -- Added keyword 'List Windows' to return a list of all window handles. - [divfor] - -- Enabled 'Select Window' to return window handle as well as accept it as locator, and - select new popup window by excluding previous window handles (the strict way) or - by special locator 'new' (the simplified but less strict way). - [divfor] - -- Added new keyword 'Wait Until Page Does Not Contain'. - [deiga] - -- Fixed ‘NoSuchWindowException' issue. Running keyword 'Select Window' after 'Close Window' - will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same - issue for keywords 'Get Window Ids', 'Get Window Titles' and 'Get Window Names'. - [divfor] - -- Corrected error message in new keyword 'Wait Until Element Is Not - Visible' to reflect element being visible instead of not visible. - [joepurdy] - -- Stop using private browsing with default Firefox profile. - [ombre42] - -- Added new keyword 'Wait Until Element Is Not Visible'. - [deiga] - -- Added new keyword 'Element Should Not Contain'. - [molsky] - -- Added new keyword 'Wait Until Page Does Not Contain Element'. - [molsky] - -- Added new keywords 'Wait Until Element Contains' and 'Wait Until Element Does Not Contain' - [molsky] - -- Added new locator strategy, scLocator, for finding SmartClient and SmartGWT elements. - [IlfirinPL] - -- Edited acceptance test scripts to automatically make known issues for the currently - known browser and python version noncritical. Also added a noncritical case to the - travis config for situations where testing is failing on travis for an unknown reason. -- 'Capture Screenshot' now attempts to create its containing directory if the directory - specified in the filename does not exist. -- 'Choose File' now fails if the file doesn't exist -- Added new keywords 'Add Location Strategy' and 'Remove Location Strategy' - [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' - keyword documentation. - [ombre42] - -- Added instructions to README.rst on how to manually install Selenium2Library. - [pekkaklarck] - -- Fixed issue where the browser failed to properly register if 'Open Browser' - did not complete. - [Mika Batsman][elizaleong][emanlove] - -- Added support for negative indices for rows and columns in table-related - keywords. - [eweitz] - -- Added strategy for locating elements by partial link text with locator - prefix 'partial link'. - [lina1] - -- Added new keyword 'Clear Element Text' for clearing the text of text entry - elements. - [emanlove] - -- Added new keyword 'Locator Should Match X Times' for validating number of - times a given locator appears. - [emanlove] - -- Fixed issue where 'Select Window’ with url strategy fails to locate window - [laulaz] - -- Fixed issue where a non-string assigned to window.id caused - 'Select Window' and 'Get Window *' keywords to fail. - [ombre42] - -- Allow using key attributes (default strategy) when the locator contains - a '=' by using the prefix 'default='. Also make locator prefixes - space-insensitive. - [ombre42] - -A big thank you to [eweitz] and [HelioGuilherme66] for getting the -continuous integration builds to go green by fixing internal tests. - -1.5 ---- -- Copy Desired Capabilities before modifying to prevent affecting future - sesions. - [ombre42] - -- Added support for Safari Browser. - [zmlpjuran] - -- Added 'Create Webdriver' to allow greater control of local WebDrivers, such - as setting a proxy or using Chrome options. - [ombre42][pekkaklarck][emanlove][j1z0] - -- Fixed Mouse Up keyword attempting to click and hold one more time before - release. - [myaskevich][emanlove] - -- Refixed issue with parsing desired capabilities. - [cookie314][ymost][emanlove] - -- Fixed compatibility with RobotFramework v2.8.1 - [F1ashhimself] - -- Modified how internal tests are run and ignore known browser issues. - [emanlove] - -1.4 ---- -- Added keywords for verifying text entered into textarea elements. - [stevejefferies][emanlove] - -- Fixed bad browser name raising AttributeError. - [ombre42] - -- Raise exception in selecting non-existing item in list. Error handling varies - between single-select and multi-select lists. See keyword documentation for - more information. - [adwu73][emanlove] - -- Added 'Get Window Size' and 'Set Window Size' keywords matching the - Selenium functionality. - [emanlove][ombre42] - -1.3 ---- -- Updated expected error messages with async javascript tests. - [emanlove] - -- Beautified README.rst. - [j1z0][emanlove] - -- Changed press key test to use Line Feed (\10) instead of - Carriage Return (\13). - [emanlove] - -- Added new keyword 'Click Element At Coordinates'. - [aaltat][pierreroth64][ombre42][emanlove] - -- Added a "Getting Help" section to README.rst. - [ombre42][emanlove] - -- Added keyword 'Wait Until Element Visible' - [ombre42] - -- Perform check on return value when finding elements. Fixes Issue 65. - [ombre42] - -- Support checking enabled/disabled state of option elements. - [ekantola] - -- Allow desired_capabilities= to be a dictionary. - [peritus] - -- Added Android and iPhone browsers. - [maddabini] - -- Added keyword 'Current Frame Should Not Contain'. - [adwu73] - -1.2 ---- -- Added PhantomJS as a supported browser type. - [bmannix] - -- Fixed 'Get Selected List Label' under IE7 or IE8. - [ombre42] - -- Added support for jQuery and sizzle selectors. - [Paul Hicks (tenwit)][peritus][j1z0] - -- Added new global variable DEFAULT_HOST to demo server for more easier - way to bind to other address than 'localhost'. - [IsNoGood] - -- Skip closed browsers when setting Selenium timeout. Fixes #93. - [ombre42] - -1.1 ---- -- Increased minimum version requirement for Selenium to 2.12.0 within - setup.py. This is required due to the change towards using Selenium's - Select class which was introduced starting in version 2.12. - [emanlove] - -- Use Selenium's Select class within Selenium2Library's "Select *" keywords. - Optimization of certain "Select *" keywords to increase performance. - [emanlove] [schminitz] - -- Replace maximize current browser window from JS to webdriver. - [jollychang] - -- Verify element is found under 'Get Text' and 'Element Should Contain' - keywords before returning text or verifing element contains specified text. - [emanlove] - -- Fixed capture page screenshot for RemoteWebDriver. - [korda] - -- Fixed issue with select window under IE. Also addresses issue with Firefox - when using selenum 2.25.0 - (see http://code.google.com/p/selenium/issues/detail?id=4375). - [adwu73] - -- Added iframe support by removing strict filtering for only elements. - [emanlove] - -- Added the 'get text' keyword to be backwards compatible with the original - Selenium Library. - [jouk0] - -- Added drag and drop support with two functions `drag and drop source - target` and `drag and drop by offset source xoffset yoffset` - [mamathanag] and [j1z0] - -- Added HTMLUnit and HTMLUnitWithJS support. Just use a line like: - `Open Browser [initial page url] remote_url=[the selenium-server url] browser=htmlunit` - [SoCalLongboard] - -1.0.1 ------ -- Support for Robot Framework 2.7 -- Improvements to distribution build script and improved documentation From aa50adec4c9722ee017bb8b2729acb8ef886df46 Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 17:58:15 +0800 Subject: [PATCH 18/24] Update CHANGES.rst --- CHANGES.rst | 242 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 242 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 8b1378917..92460957a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1 +1,243 @@ +Release Notes +============= + +1.7 (unreleased) +---------------- +- Added keyword 'List Windows' to return a list of all window handles. + [divfor] + +- Enabled 'Select Window' to return window handle as well as accept it as locator, and + select new popup window by excluding previous window handles (the strict way) or + by special locator 'new' (the simplified but less strict way). + [divfor] + +- Added new keyword 'Wait Until Page Does Not Contain'. + [deiga] + +- Fixed ‘NoSuchWindowException' issue. Running keyword 'Select Window' after 'Close Window' + will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same + issue for keywords 'Get Window Ids', 'Get Window Titles' and 'Get Window Names'. + [divfor] + +- Corrected error message in new keyword 'Wait Until Element Is Not + Visible' to reflect element being visible instead of not visible. + [joepurdy] + +- Stop using private browsing with default Firefox profile. + [ombre42] + +- Added new keyword 'Wait Until Element Is Not Visible'. + [deiga] + +- Added new keyword 'Element Should Not Contain'. + [molsky] + +- Added new keyword 'Wait Until Page Does Not Contain Element'. + [molsky] + +- Added new keywords 'Wait Until Element Contains' and 'Wait Until Element Does Not Contain' + [molsky] + +- Added new locator strategy, scLocator, for finding SmartClient and SmartGWT elements. + [IlfirinPL] + +- Edited acceptance test scripts to automatically make known issues for the currently + known browser and python version noncritical. Also added a noncritical case to the + travis config for situations where testing is failing on travis for an unknown reason. +- 'Capture Screenshot' now attempts to create its containing directory if the directory + specified in the filename does not exist. +- 'Choose File' now fails if the file doesn't exist +- Added new keywords 'Add Location Strategy' and 'Remove Location Strategy' + [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' + keyword documentation. + [ombre42] + +- Added instructions to README.rst on how to manually install Selenium2Library. + [pekkaklarck] + +- Fixed issue where the browser failed to properly register if 'Open Browser' + did not complete. + [Mika Batsman][elizaleong][emanlove] + +- Added support for negative indices for rows and columns in table-related + keywords. + [eweitz] + +- Added strategy for locating elements by partial link text with locator + prefix 'partial link'. + [lina1] + +- Added new keyword 'Clear Element Text' for clearing the text of text entry + elements. + [emanlove] + +- Added new keyword 'Locator Should Match X Times' for validating number of + times a given locator appears. + [emanlove] + +- Fixed issue where 'Select Window’ with url strategy fails to locate window + [laulaz] + +- Fixed issue where a non-string assigned to window.id caused + 'Select Window' and 'Get Window *' keywords to fail. + [ombre42] + +- Allow using key attributes (default strategy) when the locator contains + a '=' by using the prefix 'default='. Also make locator prefixes + space-insensitive. + [ombre42] + +A big thank you to [eweitz] and [HelioGuilherme66] for getting the +continuous integration builds to go green by fixing internal tests. + +1.5 +--- +- Copy Desired Capabilities before modifying to prevent affecting future + sesions. + [ombre42] + +- Added support for Safari Browser. + [zmlpjuran] + +- Added 'Create Webdriver' to allow greater control of local WebDrivers, such + as setting a proxy or using Chrome options. + [ombre42][pekkaklarck][emanlove][j1z0] + +- Fixed Mouse Up keyword attempting to click and hold one more time before + release. + [myaskevich][emanlove] + +- Refixed issue with parsing desired capabilities. + [cookie314][ymost][emanlove] + +- Fixed compatibility with RobotFramework v2.8.1 + [F1ashhimself] + +- Modified how internal tests are run and ignore known browser issues. + [emanlove] + +1.4 +--- +- Added keywords for verifying text entered into textarea elements. + [stevejefferies][emanlove] + +- Fixed bad browser name raising AttributeError. + [ombre42] + +- Raise exception in selecting non-existing item in list. Error handling varies + between single-select and multi-select lists. See keyword documentation for + more information. + [adwu73][emanlove] + +- Added 'Get Window Size' and 'Set Window Size' keywords matching the + Selenium functionality. + [emanlove][ombre42] + +1.3 +--- +- Updated expected error messages with async javascript tests. + [emanlove] + +- Beautified README.rst. + [j1z0][emanlove] + +- Changed press key test to use Line Feed (\10) instead of + Carriage Return (\13). + [emanlove] + +- Added new keyword 'Click Element At Coordinates'. + [aaltat][pierreroth64][ombre42][emanlove] + +- Added a "Getting Help" section to README.rst. + [ombre42][emanlove] + +- Added keyword 'Wait Until Element Visible' + [ombre42] + +- Perform check on return value when finding elements. Fixes Issue 65. + [ombre42] + +- Support checking enabled/disabled state of option elements. + [ekantola] + +- Allow desired_capabilities= to be a dictionary. + [peritus] + +- Added Android and iPhone browsers. + [maddabini] + +- Added keyword 'Current Frame Should Not Contain'. + [adwu73] + +1.2 +--- +- Added PhantomJS as a supported browser type. + [bmannix] + +- Fixed 'Get Selected List Label' under IE7 or IE8. + [ombre42] + +- Added support for jQuery and sizzle selectors. + [Paul Hicks (tenwit)][peritus][j1z0] + +- Added new global variable DEFAULT_HOST to demo server for more easier + way to bind to other address than 'localhost'. + [IsNoGood] + +- Skip closed browsers when setting Selenium timeout. Fixes #93. + [ombre42] + +1.1 +--- +- Increased minimum version requirement for Selenium to 2.12.0 within + setup.py. This is required due to the change towards using Selenium's + Select class which was introduced starting in version 2.12. + [emanlove] + +- Use Selenium's Select class within Selenium2Library's "Select *" keywords. + Optimization of certain "Select *" keywords to increase performance. + [emanlove] [schminitz] + +- Replace maximize current browser window from JS to webdriver. + [jollychang] + +- Verify element is found under 'Get Text' and 'Element Should Contain' + keywords before returning text or verifing element contains specified text. + [emanlove] + +- Fixed capture page screenshot for RemoteWebDriver. + [korda] + +- Fixed issue with select window under IE. Also addresses issue with Firefox + when using selenum 2.25.0 + (see http://code.google.com/p/selenium/issues/detail?id=4375). + [adwu73] + +- Added iframe support by removing strict filtering for only elements. + [emanlove] + +- Added the 'get text' keyword to be backwards compatible with the original + Selenium Library. + [jouk0] + +- Added drag and drop support with two functions `drag and drop source + target` and `drag and drop by offset source xoffset yoffset` + [mamathanag] and [j1z0] + +- Added HTMLUnit and HTMLUnitWithJS support. Just use a line like: + `Open Browser [initial page url] remote_url=[the selenium-server url] browser=htmlunit` + [SoCalLongboard] + +1.0.1 +----- +- Support for Robot Framework 2.7 +- Improvements to distribution build script and improved documentation From 9ff050e0207a34f75a1d015feb3743b3fcf5cd79 Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 21:03:27 +0800 Subject: [PATCH 19/24] update changelist --- CHANGES.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 92460957a..be4787af9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,12 +5,12 @@ Release Notes ---------------- - Added keyword 'List Windows' to return a list of all window handles. [divfor] - + - Enabled 'Select Window' to return window handle as well as accept it as locator, and select new popup window by excluding previous window handles (the strict way) or by special locator 'new' (the simplified but less strict way). [divfor] - + - Added new keyword 'Wait Until Page Does Not Contain'. [deiga] @@ -18,7 +18,7 @@ Release Notes will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same issue for keywords 'Get Window Ids', 'Get Window Titles' and 'Get Window Names'. [divfor] - + - Corrected error message in new keyword 'Wait Until Element Is Not Visible' to reflect element being visible instead of not visible. [joepurdy] @@ -240,4 +240,3 @@ continuous integration builds to go green by fixing internal tests. ----- - Support for Robot Framework 2.7 - Improvements to distribution build script and improved documentation - From 34d8562fa1747ab94023d5c9043398a449ad4398 Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 22:52:13 +0800 Subject: [PATCH 20/24] Update windowmanager.py --- src/Selenium2Library/locators/windowmanager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Selenium2Library/locators/windowmanager.py b/src/Selenium2Library/locators/windowmanager.py index 6159542f9..4003cb66d 100644 --- a/src/Selenium2Library/locators/windowmanager.py +++ b/src/Selenium2Library/locators/windowmanager.py @@ -61,7 +61,8 @@ def _select_by_url(self, browser, criteria): def _select_by_default(self, browser, criteria): if criteria is None or len(criteria) == 0 or criteria.lower() == "null": - browser.switch_to_window(browser.get_window_handles()[0]) + handles = browser.get_window_handles()[0] + browser.switch_to_window(handles[0]) return for handle in browser.get_window_handles(): browser.switch_to_window(handle) From 8e39050baefdb535aa4ac5393b796ab5fcbdfb0d Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 22:53:05 +0800 Subject: [PATCH 21/24] Update windowmanager.py --- src/Selenium2Library/locators/windowmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Selenium2Library/locators/windowmanager.py b/src/Selenium2Library/locators/windowmanager.py index 4003cb66d..d513511d8 100644 --- a/src/Selenium2Library/locators/windowmanager.py +++ b/src/Selenium2Library/locators/windowmanager.py @@ -61,7 +61,7 @@ def _select_by_url(self, browser, criteria): def _select_by_default(self, browser, criteria): if criteria is None or len(criteria) == 0 or criteria.lower() == "null": - handles = browser.get_window_handles()[0] + handles = browser.get_window_handles() browser.switch_to_window(handles[0]) return for handle in browser.get_window_handles(): From 2844643bd51f567743e1f621f2cbb9cc0147cab7 Mon Sep 17 00:00:00 2001 From: divfor Date: Fri, 5 Jun 2015 23:05:38 +0800 Subject: [PATCH 22/24] Update windowmanager.py --- src/Selenium2Library/locators/windowmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Selenium2Library/locators/windowmanager.py b/src/Selenium2Library/locators/windowmanager.py index d513511d8..b49f16f20 100644 --- a/src/Selenium2Library/locators/windowmanager.py +++ b/src/Selenium2Library/locators/windowmanager.py @@ -77,7 +77,7 @@ def _select_by_last_index(self, browser): handles = browser.get_window_handles() try: if handles[-1] == browser.get_current_window_handle(): - raise AssertionError("Unable to get new window from last index. Please use '@{ex}= | List Windows' + new window trigger + 'Select Window | ${ex}'") + raise AssertionError("No new window at last index. Please use '@{ex}= | List Windows' + new window trigger + 'Select Window | ${ex}' to find it.") except IndexError: raise AssertionError("No window found") except NoSuchWindowException: From c12e0f516cb273549312e15f319a55851a3f403e Mon Sep 17 00:00:00 2001 From: zephraph Date: Fri, 5 Jun 2015 10:26:18 -0500 Subject: [PATCH 23/24] update changes --- CHANGES.rst | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 5f9dde202..b40bac9d1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,17 +3,14 @@ Release Notes 1.7 (unreleased) ---------------- -<<<<<<< HEAD - Added keyword 'List Windows' to return a list of all window handles. [divfor] - Enabled 'Select Window' to return window handle as well as accept it as locator, and - select new popup window by excluding previous window handles (the strict way) or + select new popup window by excluding previous window handles (the strict way) or by special locator 'new' (the simplified but less strict way). [divfor] -======= ->>>>>>> master - Added new keyword 'Wait Until Page Does Not Contain'. [deiga] From 2f6a88ac62f6f2065c9ac9054710cbe7e74dadad Mon Sep 17 00:00:00 2001 From: divfor Date: Sat, 6 Jun 2015 01:20:33 +0800 Subject: [PATCH 24/24] stay at current if not found windows by default --- src/Selenium2Library/locators/windowmanager.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Selenium2Library/locators/windowmanager.py b/src/Selenium2Library/locators/windowmanager.py index b49f16f20..f7ba1ccf0 100644 --- a/src/Selenium2Library/locators/windowmanager.py +++ b/src/Selenium2Library/locators/windowmanager.py @@ -64,6 +64,10 @@ def _select_by_default(self, browser, criteria): handles = browser.get_window_handles() browser.switch_to_window(handles[0]) return + try: + starting_handle = browser.get_current_window_handle() + except NoSuchWindowException: + starting_handle = None for handle in browser.get_window_handles(): browser.switch_to_window(handle) if criteria == handle: @@ -71,6 +75,8 @@ def _select_by_default(self, browser, criteria): for item in browser.get_current_window_info()[2:4]: if item.strip().lower() == criteria.lower(): return + if starting_handle: + browser.switch_to_window(starting_handle) raise ValueError("Unable to locate window with handle or name or title or URL '" + criteria + "'") def _select_by_last_index(self, browser):