From 1e84596dcff4c34e6e08839527329ae2f2f3d3e3 Mon Sep 17 00:00:00 2001 From: Dmitriy Robota Date: Wed, 5 Oct 2016 21:55:22 -0700 Subject: [PATCH] Update travis conf --- .travis.yml | 57 ++++++++++---- requirements.txt | 2 +- setup.py | 1 - src/Selenium2Library/keywords/_element.py | 43 ++++++----- test/acceptance/create_webdriver.robot | 5 +- test/acceptance/keywords/click_element.robot | 2 +- .../click_element_at_coordinates.robot | 4 +- test/acceptance/keywords/cookies.robot | 2 + test/acceptance/keywords/elements.robot | 11 +-- .../keywords/forms_and_buttons.robot | 1 + test/acceptance/keywords/javascript.robot | 12 ++- test/acceptance/keywords/lists.robot | 1 + test/acceptance/keywords/mouse.robot | 9 ++- test/acceptance/keywords/navigation.robot | 3 + test/acceptance/keywords/run_on_failure.robot | 1 + test/acceptance/keywords/screenshots.robot | 1 + .../acceptance/keywords/tables/__init__.robot | 2 +- test/acceptance/keywords/textfields.robot | 1 + test/acceptance/keywords/waiting.robot | 1 + test/acceptance/multiple_browsers.robot | 1 + test/acceptance/resource.robot | 16 ++-- test/acceptance/windows.robot | 10 ++- test/env.py | 10 ++- test/resources/statuschecker.py | 9 ++- test/resources/testserver/testserver.py | 8 +- test/run_tests.py | 74 ++++++++++++------- test/run_unit_tests.py | 2 +- 27 files changed, 198 insertions(+), 91 deletions(-) diff --git a/.travis.yml b/.travis.yml index 92e5beafa..1c70079ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,24 +2,51 @@ addons: firefox: latest-esr language: python sudo: false -python: - - "2.7" install: - #- pip install pep8 --use-mirrors - #- pip install pyflakes --use-mirrors - - pip install robotframework - - pip install selenium==2.53.6 - - pip install decorator - - pip install mockito - #- "if [[ ${BROWSER} == 'ie' ]]; then pip install ie_only_pkg; fi" + - pip install . + - pip install -r requirements.txt + - pip install -r requirements-dev.txt before_script: - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" script: - - "firefox --version" - - "python test/run_tests.py python $BROWSER --noncritical known_issue_-_travisci" + - "if [[ -n ${SELENIUM_VERSION+x} ]]; then pip install -U selenium==${SELENIUM_VERSION}; fi" + - "python test/run_tests.py python \"$BROWSER\"" env: - matrix: - - BROWSER=firefox - #- BROWSER=ie # will be added when we have completed SauceLabs CI - #- BROWSER=safari # will be added after #247 merged + global: + - secure: "QyY0j8C+hVhsGLv4YU0UMvLm5wBDg6xT5J0Ee77C/JAQ6vcdCMpTfWI8oDxTZb7pBhpDkYuNe747yCYF5PrdBYQbO08FilxctReuJfMXcH44rZC5q49mUmPamkvg1LkzIWuC1s9uKnjlvyDT5ojuPXZl2Vn0gIhSIg+yOyBkM1U=" + - secure: "HJaJTYauaBZODMDkbnRVsiCk+t2uVtztkkJ5V4dXSnE1uIBms2PVbufQwb+YNvzHkGheLtpnt/hLM1HhmSFgUtOCf+eumQ6kaLR2KRVEysXwWJzgZoLBidNBOy5rvAIsc9JJbDaIgYVGzyaJGTP9AMb8CyvIPE//lH10sf+GB7g=" +matrix: + include: + - os: linux + env: + - BROWSER=firefox + - SELENIUM_VERSION=2.53.6 + addons: + firefox: "47.0.1" + python: "2.7" + - os: linux + env: + - BROWSER=chrome + addons: + sauce_connect: true + python: "2.7" + - os: linux + env: + - BROWSER=firefox + - SELENIUM_VERSION=2.53.6 + addons: + sauce_connect: true + python: "3.4" + - os: linux + env: + - BROWSER="internet explorer" + addons: + sauce_connect: true + python: "2.7" + - os: linux + env: + - BROWSER=safari + addons: + sauce_connect: true + python: "2.7" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index b266dec99..1965bcaa2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ decorator >= 3.3.2 -selenium >= 2.32.0 +selenium robotframework >= 2.6.0 diff --git a/setup.py b/setup.py index 1897429ed..bb4fa0795 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,6 @@ #!/usr/bin/env python from os.path import abspath, dirname, join - from setuptools import setup diff --git a/src/Selenium2Library/keywords/_element.py b/src/Selenium2Library/keywords/_element.py index a5e2fc040..4654d8a6a 100644 --- a/src/Selenium2Library/keywords/_element.py +++ b/src/Selenium2Library/keywords/_element.py @@ -5,8 +5,16 @@ from Selenium2Library import utils from Selenium2Library.locators import ElementFinder from Selenium2Library.locators import CustomLocator +from Selenium2Library.keywords.keywordgroup import KeywordGroup -from .keywordgroup import KeywordGroup +try: + basestring # attempt to evaluate basestring + + def isstr(s): + return isinstance(s, basestring) +except NameError: + def isstr(s): + return isinstance(s, str) class _ElementKeywords(KeywordGroup): @@ -358,9 +366,11 @@ def click_element_at_coordinates(self, locator, xoffset, yoffset): """ self._info("Click clicking element '%s' in coordinates '%s', '%s'." % (locator, xoffset, yoffset)) element = self._element_find(locator, True, True) - #self._element_find(locator, True, True).click() - #ActionChains(self._current_browser()).move_to_element_with_offset(element, xoffset, yoffset).click().perform() - ActionChains(self._current_browser()).move_to_element(element).move_by_offset(xoffset, yoffset).click().perform() + action = ActionChains(self._current_browser()) + action.move_to_element(element) + action.move_by_offset(xoffset, yoffset) + action.click() + action.perform() def double_click_element(self, locator): """Double click element identified by `locator`. @@ -389,11 +399,10 @@ def drag_and_drop(self, source, target): Examples: | Drag And Drop | elem1 | elem2 | # Move elem1 over elem2. | """ - src_elem = self._element_find(source,True,True) - trg_elem = self._element_find(target,True,True) + src_elem = self._element_find(source, True, True) + trg_elem = self._element_find(target, True, True) ActionChains(self._current_browser()).drag_and_drop(src_elem, trg_elem).perform() - def drag_and_drop_by_offset(self, source, xoffset, yoffset): """Drags element identified with `source` which is a locator. @@ -404,7 +413,9 @@ def drag_and_drop_by_offset(self, source, xoffset, yoffset): | Drag And Drop By Offset | myElem | 50 | -35 | # Move myElem 50px right and 35px down. | """ src_elem = self._element_find(source, True, True) - ActionChains(self._current_browser()).drag_and_drop_by_offset(src_elem, xoffset, yoffset).perform() + action = ActionChains(self._current_browser()) + action.drag_and_drop_by_offset(src_elem, xoffset, yoffset) + action.perform() def mouse_down(self, locator): """Simulates pressing the left mouse button on the element specified by `locator`. @@ -582,7 +593,6 @@ def mouse_down_on_image(self, locator): def page_should_contain_image(self, locator, message='', loglevel='INFO'): """Verifies image identified by `locator` is found from current page. - See `Page Should Contain Element` for explanation about `message` and `loglevel` arguments. @@ -723,7 +733,7 @@ def _is_enabled(self, locator): return True def _is_text_present(self, text): - locator = "xpath=//*[contains(., %s)]" % utils.escape_xpath_value(text); + locator = "xpath=//*[contains(., %s)]" % utils.escape_xpath_value(text) return self._is_element_present(locator) def _is_visible(self, locator): @@ -759,11 +769,11 @@ def _map_ascii_key_code_to_key(self, key_code): def _map_named_key_code_to_special_key(self, key_name): try: - return getattr(Keys, key_name) + return getattr(Keys, key_name) except AttributeError: - message = "Unknown key named '%s'." % (key_name) - self._debug(message) - raise ValueError(message) + message = "Unknown key named '%s'." % (key_name) + self._debug(message) + raise ValueError(message) def _parse_attribute_locator(self, attribute_locator): parts = attribute_locator.rpartition('@') @@ -771,10 +781,10 @@ def _parse_attribute_locator(self, attribute_locator): raise ValueError("Attribute locator '%s' does not contain an element locator." % (attribute_locator)) if len(parts[2]) == 0: raise ValueError("Attribute locator '%s' does not contain an attribute name." % (attribute_locator)) - return (parts[0], parts[2]) + return parts[0], parts[2] def _is_element_present(self, locator, tag=None): - return (self._element_find(locator, True, False, tag=tag) is not None) + return self._element_find(locator, True, False, tag=tag) is not None def _page_contains(self, text): browser = self._current_browser() @@ -791,7 +801,6 @@ def _page_contains(self, text): browser.switch_to_default_content() if found_text: return True - return False def _page_should_contain_element(self, locator, tag, message, loglevel): diff --git a/test/acceptance/create_webdriver.robot b/test/acceptance/create_webdriver.robot index faf173d3d..6f902827d 100644 --- a/test/acceptance/create_webdriver.robot +++ b/test/acceptance/create_webdriver.robot @@ -7,10 +7,11 @@ Library Collections Create Webdriver Creates Functioning WebDriver [Documentation] LOG 2:1 INFO REGEXP: Creating an instance of the \\w+ WebDriver ... LOG 2:4 DEBUG REGEXP: Created \\w+ WebDriver instance with session id (\\w|-)+ + [Tags] Known Issue Chrome Known Issue Internet Explorer Known Issue Safari [Setup] Set Driver Variables Create Webdriver ${DRIVER_NAME} kwargs=${KWARGS} - Go To ${FRONT PAGE} - Page Should Contain needle + Go To ${FRONT_PAGE} + Wait Until Page Contains needle 5s [Teardown] Close Browser Create Webdriver With Bad Driver Name diff --git a/test/acceptance/keywords/click_element.robot b/test/acceptance/keywords/click_element.robot index c820b14a0..97ed96a62 100644 --- a/test/acceptance/keywords/click_element.robot +++ b/test/acceptance/keywords/click_element.robot @@ -12,7 +12,7 @@ Click Element Double Click Element [Documentation] LOG 2 Double clicking element 'doubleClickButton'. - [Tags] Known Issue - Firefox + [Tags] Known Issue Safari Known Issue Firefox Double Click Element doubleClickButton Element Text Should Be output double clicked diff --git a/test/acceptance/keywords/click_element_at_coordinates.robot b/test/acceptance/keywords/click_element_at_coordinates.robot index 32e08a602..961a8714e 100644 --- a/test/acceptance/keywords/click_element_at_coordinates.robot +++ b/test/acceptance/keywords/click_element_at_coordinates.robot @@ -7,7 +7,9 @@ Resource ../resource.robot *** Test Cases *** Click Element At Coordinates [Documentation] LOG 2 Click clicking element 'Clickable' in coordinates '10', '20'. - [Tags] Known Issue - Firefox + [Tags] Known Issue Firefox + ... Known Issue Internet Explorer + ... Known Issue Safari Click Element At Coordinates Clickable ${10} ${20} Element Text Should Be outputX 110 Element Text Should Be outputY 120 diff --git a/test/acceptance/keywords/cookies.robot b/test/acceptance/keywords/cookies.robot index 902d46fde..e3fb40dcc 100644 --- a/test/acceptance/keywords/cookies.robot +++ b/test/acceptance/keywords/cookies.robot @@ -31,6 +31,7 @@ App Sees Cookie Set By Selenium Delete Cookie [Documentation] Delete Cookie + [Tags] Known Issue Safari Delete Cookie test ${cookies} = Get Cookies Should Be Equal ${cookies} another=value @@ -42,6 +43,7 @@ Non-existent Cookie Get Cookies When There Are None [Documentation] Get Cookies When There Are None + [Tags] Known Issue Safari Delete All Cookies ${cookies}= Get Cookies Should Be Equal ${cookies} ${EMPTY} diff --git a/test/acceptance/keywords/elements.robot b/test/acceptance/keywords/elements.robot index 583d4b6fd..74bd2fa64 100644 --- a/test/acceptance/keywords/elements.robot +++ b/test/acceptance/keywords/elements.robot @@ -72,11 +72,12 @@ Get Vertical Position Get Element Size - ${width} ${height}= Get Element Size link=Link - Should be True ${height} > ${0} - Should be True ${width} > ${0} - Run Keyword And Expect Error ValueError: Element locator 'non-existent' did not match any elements. Get Element Size non-existent + ${width} ${height}= Get Element Size link=Link + Should be True ${height} > ${0} + Should be True ${width} > ${0} + Run Keyword And Expect Error ValueError: Element locator 'non-existent' did not match any elements. Get Element Size non-existent Get Empty Element Size + [Tags] Known Issue Internet Explorer ${width} ${height}= Get Element Size id=emptyDiv - Should be True ${height} == 0 + Should be True ${height} == 0 diff --git a/test/acceptance/keywords/forms_and_buttons.robot b/test/acceptance/keywords/forms_and_buttons.robot index aac4a7444..d4346bccb 100644 --- a/test/acceptance/keywords/forms_and_buttons.robot +++ b/test/acceptance/keywords/forms_and_buttons.robot @@ -60,6 +60,7 @@ Click button created with