From 99b4b3f70328a934c3a8dbc1d9982a4f1fe9111a Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 11:18:30 +0200 Subject: [PATCH 01/17] Update .travis.yml --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 22194fb0a..afe5886fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ before_install: - unzip chromedriver_linux64.zip - sudo chmod u+x chromedriver - sudo mv chromedriver /usr/bin/ + - pip install --upgrade pip install: - pip install . - pip install -r requirements.txt @@ -34,12 +35,12 @@ matrix: - BROWSER=chrome - SELENIUM=3.3.1 - ROBOTFRAMEWORK=2.8.7 - - python: "3.3" # For PR and cron + - python: "3.6" # For PR and cron env: - BROWSER=chrome - SELENIUM=2.53.6 - ROBOTFRAMEWORK=3.0.2 - - python: "3.3" # For cron only + - python: "3.6" # For cron only env: - BROWSER=firefox - SELENIUM=2.53.6 From dcba5929af56c5cc5a6b4e9ede8b6b06454ee5b0 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 11:28:39 +0200 Subject: [PATCH 02/17] unicode() is unnecessary in Python 3 --- src/Selenium2Library/utils/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Selenium2Library/utils/__init__.py b/src/Selenium2Library/utils/__init__.py index f43c24c57..092c83fd8 100644 --- a/src/Selenium2Library/utils/__init__.py +++ b/src/Selenium2Library/utils/__init__.py @@ -4,7 +4,10 @@ def escape_xpath_value(value): - value = unicode(value) + try: + value = unicode(value) # Python 2 + except NameError: + pass # Python 3 if '"' in value and '\'' in value: parts_wo_apos = value.split('\'') return "concat('%s')" % "', \"'\", '".join(parts_wo_apos) From 9981ab5a39482b1bd7f5d8620aed3c165dc6258f Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 11:50:01 +0200 Subject: [PATCH 03/17] Try without sudo to allow travis to test in parallel --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index afe5886fb..bcb0f49b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: python -sudo: required +# sudo: required # allow travis to test in parallel dist: trusty addons: apt: From 796c42d93704580772306d574b951e1f8ff2d025 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 11:56:38 +0200 Subject: [PATCH 04/17] unicode is not necessary in Python 3 --- src/Selenium2Library/keywords/browsermanagement.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Selenium2Library/keywords/browsermanagement.py b/src/Selenium2Library/keywords/browsermanagement.py index edf969248..036dc8c57 100644 --- a/src/Selenium2Library/keywords/browsermanagement.py +++ b/src/Selenium2Library/keywords/browsermanagement.py @@ -625,6 +625,11 @@ def _create_remote_web_driver(self , capabilities_type , remote_url , desired_ca creates the associated remote web driver''' desired_capabilities_object = capabilities_type.copy() + + try: + unicode # Python 2 + except NameError: + unicode = str # Python 3 if type(desired_capabilities) in (str, unicode): desired_capabilities = self._parse_capabilities_string(desired_capabilities) From 3ccdf775b59f722b6ec70cf8206bdf2142020738 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 12:08:42 +0200 Subject: [PATCH 05/17] sudo: false --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bcb0f49b6..f81652134 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: python -# sudo: required # allow travis to test in parallel +sudo: false # allow travis to test in parallel dist: trusty addons: apt: From 1cfab9374c51ecaa3c856609aae07eef272acd15 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 12:12:03 +0200 Subject: [PATCH 06/17] basestring is undefined in Python 3 --- src/Selenium2Library/locators/customlocator.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Selenium2Library/locators/customlocator.py b/src/Selenium2Library/locators/customlocator.py index 6f68752d7..e9b59ccfa 100644 --- a/src/Selenium2Library/locators/customlocator.py +++ b/src/Selenium2Library/locators/customlocator.py @@ -1,5 +1,10 @@ from robot.libraries.BuiltIn import BuiltIn +try: + unicode # Python 2 +except NameError: + unicode = str # Python 3 + class CustomLocator(object): From 7ca0b6b6dba6464dd2a2d97f1c4105cc9672d361 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 12:13:41 +0200 Subject: [PATCH 07/17] Update customlocator.py --- src/Selenium2Library/locators/customlocator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Selenium2Library/locators/customlocator.py b/src/Selenium2Library/locators/customlocator.py index e9b59ccfa..6c81d43e6 100644 --- a/src/Selenium2Library/locators/customlocator.py +++ b/src/Selenium2Library/locators/customlocator.py @@ -1,9 +1,9 @@ from robot.libraries.BuiltIn import BuiltIn try: - unicode # Python 2 + basestring # Python 2 except NameError: - unicode = str # Python 3 + basestring = str # Python 3 class CustomLocator(object): From 30e608a2cce4c1930e8870587fc1b5bc3c757067 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 12:14:52 +0200 Subject: [PATCH 08/17] basestring is undefined in Python 3 --- src/Selenium2Library/keywords/element.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Selenium2Library/keywords/element.py b/src/Selenium2Library/keywords/element.py index 3c6bf57f3..df652044c 100644 --- a/src/Selenium2Library/keywords/element.py +++ b/src/Selenium2Library/keywords/element.py @@ -699,6 +699,10 @@ def remove_location_strategy(self, strategy_name): # Private def _element_find(self, locator, first_only, required, tag=None): + try: + basestring # Python 2 + except NameError: + basestring = str # Python 3 browser = self._current_browser() if isinstance(locator, basestring): elements = self._element_finder.find(browser, locator, tag) From ab48c5719e086d883a8bf18cc0fa55357a93bc8a Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 12:17:16 +0200 Subject: [PATCH 09/17] No sudo? --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f81652134..331c6918c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,10 @@ before_install: - CDVERSION=`curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE` - wget http://chromedriver.storage.googleapis.com/$CDVERSION/chromedriver_linux64.zip - unzip chromedriver_linux64.zip - - sudo chmod u+x chromedriver - - sudo mv chromedriver /usr/bin/ + - # sudo chmod u+x chromedriver + - # sudo mv chromedriver /usr/bin/ + - chmod u+x chromedriver + - mv chromedriver /usr/bin/ - pip install --upgrade pip install: - pip install . From 7a9d1bee8abccf0edc2570b2612f93894d97101c Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 12:27:23 +0200 Subject: [PATCH 10/17] sudo: required # No travis tests on Docker :-( https://docs.travis-ci.com/user/trusty-ci-environment/ --- .travis.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 331c6918c..afe5886fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: python -sudo: false # allow travis to test in parallel +sudo: required dist: trusty addons: apt: @@ -11,10 +11,8 @@ before_install: - CDVERSION=`curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE` - wget http://chromedriver.storage.googleapis.com/$CDVERSION/chromedriver_linux64.zip - unzip chromedriver_linux64.zip - - # sudo chmod u+x chromedriver - - # sudo mv chromedriver /usr/bin/ - - chmod u+x chromedriver - - mv chromedriver /usr/bin/ + - sudo chmod u+x chromedriver + - sudo mv chromedriver /usr/bin/ - pip install --upgrade pip install: - pip install . From 249a72195901e50b147bd50b1f1e442d1141ed64 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 12:51:07 +0200 Subject: [PATCH 11/17] Update element.py --- src/Selenium2Library/keywords/element.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Selenium2Library/keywords/element.py b/src/Selenium2Library/keywords/element.py index df652044c..fb800f855 100644 --- a/src/Selenium2Library/keywords/element.py +++ b/src/Selenium2Library/keywords/element.py @@ -699,6 +699,7 @@ def remove_location_strategy(self, strategy_name): # Private def _element_find(self, locator, first_only, required, tag=None): + print('locator ({}): {}'.format(type(locator), locator)) try: basestring # Python 2 except NameError: @@ -713,6 +714,8 @@ def _element_find(self, locator, first_only, required, tag=None): return elements[0] elif isinstance(locator, WebElement): elements = locator + else: + elements = [] # do some other stuff here like deal with list of webelements # ... or raise locator/element specific error if required return elements From cf326aa52be9edad76631c5242912c3452a5957f Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 13:01:29 +0200 Subject: [PATCH 12/17] basestring = bytes --- src/Selenium2Library/keywords/element.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Selenium2Library/keywords/element.py b/src/Selenium2Library/keywords/element.py index fb800f855..fbbd41f81 100644 --- a/src/Selenium2Library/keywords/element.py +++ b/src/Selenium2Library/keywords/element.py @@ -699,23 +699,21 @@ def remove_location_strategy(self, strategy_name): # Private def _element_find(self, locator, first_only, required, tag=None): - print('locator ({}): {}'.format(type(locator), locator)) try: - basestring # Python 2 + basestring # Python 2 except NameError: - basestring = str # Python 3 + basestring = bytes # Python 3 browser = self._current_browser() if isinstance(locator, basestring): elements = self._element_finder.find(browser, locator, tag) if required and len(elements) == 0: raise ValueError("Element locator '" + locator + "' did not match any elements.") if first_only: - if len(elements) == 0: return None + if len(elements) == 0: + return None return elements[0] elif isinstance(locator, WebElement): elements = locator - else: - elements = [] # do some other stuff here like deal with list of webelements # ... or raise locator/element specific error if required return elements From 6c616c2d04cc80af9be0f0b25ce1a5aca004585c Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 13:15:22 +0200 Subject: [PATCH 13/17] elements = locator isinstance(locator, WebElement) else None --- src/Selenium2Library/keywords/element.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Selenium2Library/keywords/element.py b/src/Selenium2Library/keywords/element.py index fbbd41f81..87df30d58 100644 --- a/src/Selenium2Library/keywords/element.py +++ b/src/Selenium2Library/keywords/element.py @@ -700,9 +700,9 @@ def remove_location_strategy(self, strategy_name): def _element_find(self, locator, first_only, required, tag=None): try: - basestring # Python 2 + basestring # Python 2 except NameError: - basestring = bytes # Python 3 + basestring = str # Python 3 browser = self._current_browser() if isinstance(locator, basestring): elements = self._element_finder.find(browser, locator, tag) @@ -712,8 +712,9 @@ def _element_find(self, locator, first_only, required, tag=None): if len(elements) == 0: return None return elements[0] - elif isinstance(locator, WebElement): - elements = locator + else: + elements = locator isinstance(locator, WebElement) else None + # do some other stuff here like deal with list of webelements # ... or raise locator/element specific error if required return elements From abe6ebbc51cb36d19668e299e4549fb408d26f50 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 13:16:16 +0200 Subject: [PATCH 14/17] elements = locator if isinstance(locator, WebElement) else None --- src/Selenium2Library/keywords/element.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Selenium2Library/keywords/element.py b/src/Selenium2Library/keywords/element.py index 87df30d58..2eec773fc 100644 --- a/src/Selenium2Library/keywords/element.py +++ b/src/Selenium2Library/keywords/element.py @@ -713,7 +713,7 @@ def _element_find(self, locator, first_only, required, tag=None): return None return elements[0] else: - elements = locator isinstance(locator, WebElement) else None + elements = locator if isinstance(locator, WebElement) else None # do some other stuff here like deal with list of webelements # ... or raise locator/element specific error if required From 3037fe4c04e4701b6f2ba88335de94b425037e35 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 13:26:00 +0200 Subject: [PATCH 15/17] Revert to no changes --- src/Selenium2Library/keywords/element.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Selenium2Library/keywords/element.py b/src/Selenium2Library/keywords/element.py index 2eec773fc..25a017679 100644 --- a/src/Selenium2Library/keywords/element.py +++ b/src/Selenium2Library/keywords/element.py @@ -699,21 +699,16 @@ def remove_location_strategy(self, strategy_name): # Private def _element_find(self, locator, first_only, required, tag=None): - try: - basestring # Python 2 - except NameError: - basestring = str # Python 3 browser = self._current_browser() if isinstance(locator, basestring): elements = self._element_finder.find(browser, locator, tag) if required and len(elements) == 0: raise ValueError("Element locator '" + locator + "' did not match any elements.") if first_only: - if len(elements) == 0: - return None + if len(elements) == 0: return None return elements[0] - else: - elements = locator if isinstance(locator, WebElement) else None + elif isinstance(locator, WebElement): + elements = locator # do some other stuff here like deal with list of webelements # ... or raise locator/element specific error if required From 18d87d7a34095562eba0e8cdcf947820741fad0b Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 13:26:53 +0200 Subject: [PATCH 16/17] Revert to no changes --- src/Selenium2Library/keywords/element.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Selenium2Library/keywords/element.py b/src/Selenium2Library/keywords/element.py index 25a017679..3c6bf57f3 100644 --- a/src/Selenium2Library/keywords/element.py +++ b/src/Selenium2Library/keywords/element.py @@ -708,8 +708,7 @@ def _element_find(self, locator, first_only, required, tag=None): if len(elements) == 0: return None return elements[0] elif isinstance(locator, WebElement): - elements = locator - + elements = locator # do some other stuff here like deal with list of webelements # ... or raise locator/element specific error if required return elements From d0376684850a1d5aaeb8a186f61e0f75be971ce3 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 11 Apr 2017 13:43:50 +0200 Subject: [PATCH 17/17] basestring is not defined in Python 3 --- src/Selenium2Library/keywords/element.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Selenium2Library/keywords/element.py b/src/Selenium2Library/keywords/element.py index 3c6bf57f3..8e2c9b326 100644 --- a/src/Selenium2Library/keywords/element.py +++ b/src/Selenium2Library/keywords/element.py @@ -8,6 +8,10 @@ from .keywordgroup import KeywordGroup +try: + basestring # Python 2 +except NameError: + basestring = str # Python 3 class ElementKeywords(KeywordGroup):