diff --git a/.travis.yml b/.travis.yml
index 92e5beafa..05a99e7c5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,13 +4,16 @@ language: python
sudo: false
python:
- "2.7"
+ - "3.4"
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
+ - pip install robotframework
+ - pip install selenium==2.53.6
+ - pip install decorator
+ - pip install docutils
+ - pip install future
+ - pip install mockito
#- "if [[ ${BROWSER} == 'ie' ]]; then pip install ie_only_pkg; fi"
before_script:
- "export DISPLAY=:99.0"
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
new file mode 100644
index 000000000..002504a5b
--- /dev/null
+++ b/ISSUE_TEMPLATE.md
@@ -0,0 +1,52 @@
+## Prerequisites
+
+- [ ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate
+- [ ] The issue still exists against the latest `master` branch of Selenium2Library
+- [ ] This is not a usage question (Those should be directed to the
+ [google groups](http://groups.google.com/group/robotframework-users/) or
+ [slack chat](https://robotframework-slack.herokuapp.com/))
+- [ ] I have attempted to find the simplest possible steps to reproduce the issue
+- [ ] I have included a failing test as a pull request (Optional)
+
+## Steps to reproduce the issue
+
+1. _
+2. _
+3. _
+
+## Expected behavior and actual behavior
+
+When I follow those steps, I see...
+
+I was expecting...
+
+## Environment
+
+Browsers
+
+- [ ] Internet Explorer (version: )
+- [ ] Google Chrome (version: )
+- [ ] Mozilla Firefox (version: )
+- [ ] Opera (version: )
+- [ ] PhantomJS (version: )
+- [ ] Safari (Mac OS X) (version: )
+
+Operating System
+
+- [ ] Windows (version: )
+- [ ] Mac OS X (version: )
+- [ ] Linux (version: distro: )
+
+Libraries
+
+- Robot Framework version:
+- Selenium version:
+- Selenium2Library ([x] Python or [ ] Jython) version:
+
+## Isolating and demonstrating the problem
+
+- [ ] This bug happens when testing a public site: [example](http://example.org/)
+- [ ] The bug happens consistently across all tested browsers
+- [ ] The Robot Framework Test file or snippet is attached or
+ at [some public site](http://pastebin.com/)
+- [ ] The Test was called from: [ ] Local machine [ ] Remote Automation (Jenkins CI)
diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 000000000..543abf704
--- /dev/null
+++ b/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,14 @@
+This pull request includes a
+
+- [ ] An improvement
+- [ ] Bug fix
+- [ ] New feature
+
+
+The following changes were made
+
+-
+-
+-
+
+If this is related to an existing ticket, include a link to it as well.
diff --git a/build_dist.py b/build_dist.py
index 6b5dd3530..3a8f1d99d 100644
--- a/build_dist.py
+++ b/build_dist.py
@@ -1,6 +1,11 @@
#!/usr/bin/env python
-import os, sys, shutil, subprocess, argparse
+from __future__ import print_function
+import os
+import sys
+import shutil
+import subprocess
+import argparse
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
DIST_DIR = os.path.join(THIS_DIR, "dist")
@@ -9,9 +14,9 @@
sys.path.append(os.path.join(THIS_DIR, "demo"))
def main():
- parser = argparse.ArgumentParser(description="Builds a Se2Lib distribution")
- parser.add_argument('py_26_path', action='store', help='Python 2.6 executbale file path')
- parser.add_argument('py_27_path', action='store', help='Python 2.7 executbale file path')
+ parser = argparse.ArgumentParser(description="Builds a Selenium2Library distribution")
+ parser.add_argument('py_26_path', action='store', help='Python 2.6 executable file path')
+ parser.add_argument('py_27_path', action='store', help='Python 2.7 executable file path')
parser.add_argument('--release', action='store_true')
parser.add_argument('--winonly', action='store_true')
args = parser.parse_args()
@@ -33,7 +38,7 @@ def clear_dist_folder():
def run_doc_gen():
import generate
- print
+ print()
generate.main()
def run_register(args):
@@ -41,7 +46,7 @@ def run_register(args):
_run_setup(args.py_27_path, "register", [], False)
def run_builds(args):
- print
+ print()
if not args.winonly:
_run_setup(args.py_27_path, "sdist", [ "--formats=gztar,zip" ], args.release)
_run_setup(args.py_26_path, "bdist_egg", [], args.release)
@@ -50,12 +55,12 @@ def run_builds(args):
_run_setup(args.py_27_path, "bdist_wininst", [ "--plat-name=win32" ], args.release)
_run_setup(args.py_27_path, "bdist_wininst", [ "--plat-name=win-amd64" ], args.release)
else:
- print
+ print()
print("Windows binary installers cannot be built on this platform!")
def run_demo_packaging():
import package
- print
+ print()
package.main()
def _run_setup(py_path, type, params, upload):
@@ -66,8 +71,8 @@ def _run_setup(py_path, type, params, upload):
if upload:
setup_args.append("upload")
- print
- print("Running: %s" % ' '.join(setup_args))
+ print()
+ print("Running: {0}".format(' '.join(setup_args)))
returncode = subprocess.call(setup_args)
if returncode != 0:
print("Error running setup.py")
diff --git a/docs/Selenium2Library.html b/docs/Selenium2Library.html
index ab468cb8c..93a1aa2fb 100644
--- a/docs/Selenium2Library.html
+++ b/docs/Selenium2Library.html
@@ -1,832 +1,832 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Opening library documentation failed
-
- - Verify that you have JavaScript enabled in your browser.
- - Make sure you are using a modern enough browser. Firefox 3.5, IE 8, or equivalent is required, newer browsers are recommended.
- - Check are there messages in your browser's JavaScript error log. Please report the problem if you suspect you have encountered a bug.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Opening library documentation failed
+
+ - Verify that you have JavaScript enabled in your browser.
+ - Make sure you are using a modern enough browser. Firefox 3.5, IE 8, or equivalent is required, newer browsers are recommended.
+ - Check are there messages in your browser's JavaScript error log. Please report the problem if you suspect you have encountered a bug.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/generate.py b/docs/generate.py
index 08ca44889..8eb445538 100755
--- a/docs/generate.py
+++ b/docs/generate.py
@@ -1,14 +1,17 @@
#!/usr/bin/env python
+
+from __future__ import print_function
from os.path import join, dirname
+
try:
from robot.libdoc import libdoc
except:
def main():
- print """Robot Framework 2.7 or later required for generating documentation"""
+ print('"""Robot Framework 2.7 or later required for generating documentation"""')
else:
def main():
libdoc(join(dirname(__file__),'..','src','Selenium2Library'), join(dirname(__file__),'Selenium2Library.html'))
if __name__ == '__main__':
- main()
\ No newline at end of file
+ main()
diff --git a/src/Selenium2Library/__init__.py b/src/Selenium2Library/__init__.py
index bd23f053b..dae933762 100644
--- a/src/Selenium2Library/__init__.py
+++ b/src/Selenium2Library/__init__.py
@@ -1,7 +1,8 @@
+from __future__ import absolute_import
import os
-from keywords import *
-from version import VERSION
-from utils import LibraryListener
+from Selenium2Library.keywords import *
+from .version import VERSION
+from .utils import LibraryListener
__version__ = VERSION
diff --git a/src/Selenium2Library/keywords/__init__.py b/src/Selenium2Library/keywords/__init__.py
index 431bb107c..09ff409a7 100644
--- a/src/Selenium2Library/keywords/__init__.py
+++ b/src/Selenium2Library/keywords/__init__.py
@@ -1,15 +1,16 @@
-from _logging import _LoggingKeywords
-from _runonfailure import _RunOnFailureKeywords
-from _browsermanagement import _BrowserManagementKeywords
-from _element import _ElementKeywords
-from _tableelement import _TableElementKeywords
-from _formelement import _FormElementKeywords
-from _selectelement import _SelectElementKeywords
-from _javascript import _JavaScriptKeywords
-from _cookie import _CookieKeywords
-from _screenshot import _ScreenshotKeywords
-from _waiting import _WaitingKeywords
-from _alert import _AlertKeywords
+from __future__ import absolute_import
+from ._logging import _LoggingKeywords
+from ._runonfailure import _RunOnFailureKeywords
+from ._browsermanagement import _BrowserManagementKeywords
+from ._element import _ElementKeywords
+from ._tableelement import _TableElementKeywords
+from ._formelement import _FormElementKeywords
+from ._selectelement import _SelectElementKeywords
+from ._javascript import _JavaScriptKeywords
+from ._cookie import _CookieKeywords
+from ._screenshot import _ScreenshotKeywords
+from ._waiting import _WaitingKeywords
+from ._alert import _AlertKeywords
__all__ = [
"_LoggingKeywords",
diff --git a/src/Selenium2Library/keywords/_alert.py b/src/Selenium2Library/keywords/_alert.py
index 07f6faf30..7237d075d 100644
--- a/src/Selenium2Library/keywords/_alert.py
+++ b/src/Selenium2Library/keywords/_alert.py
@@ -1,8 +1,9 @@
+from __future__ import absolute_import
import time
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
-from keywordgroup import KeywordGroup
+from .keywordgroup import KeywordGroup
class _AlertKeywords(KeywordGroup):
diff --git a/src/Selenium2Library/keywords/_browsermanagement.py b/src/Selenium2Library/keywords/_browsermanagement.py
index e3a15ee56..747e05aaa 100644
--- a/src/Selenium2Library/keywords/_browsermanagement.py
+++ b/src/Selenium2Library/keywords/_browsermanagement.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+from builtins import str
import os
import robot
from robot.errors import DataError
@@ -5,7 +7,7 @@
from Selenium2Library import webdrivermonkeypatches
from Selenium2Library.utils import BrowserCache
from Selenium2Library.locators import WindowManager
-from keywordgroup import KeywordGroup
+from .keywordgroup import KeywordGroup
from selenium.common.exceptions import NoSuchWindowException
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
@@ -611,7 +613,7 @@ def _create_remote_web_driver(self , capabilities_type , remote_url , desired_ca
desired_capabilities_object = capabilities_type.copy()
- if type(desired_capabilities) in (str, unicode):
+ if type(desired_capabilities) in (str, str):
desired_capabilities = self._parse_capabilities_string(desired_capabilities)
desired_capabilities_object.update(desired_capabilities or {})
diff --git a/src/Selenium2Library/keywords/_cookie.py b/src/Selenium2Library/keywords/_cookie.py
index a97808f06..ef6029224 100644
--- a/src/Selenium2Library/keywords/_cookie.py
+++ b/src/Selenium2Library/keywords/_cookie.py
@@ -1,4 +1,5 @@
-from keywordgroup import KeywordGroup
+from __future__ import absolute_import
+from .keywordgroup import KeywordGroup
class _CookieKeywords(KeywordGroup):
diff --git a/src/Selenium2Library/keywords/_element.py b/src/Selenium2Library/keywords/_element.py
index 357ff1bd5..0fe88a7d3 100644
--- a/src/Selenium2Library/keywords/_element.py
+++ b/src/Selenium2Library/keywords/_element.py
@@ -1,10 +1,16 @@
+from __future__ import division
+from __future__ import absolute_import
+from builtins import str
+from builtins import chr
+from past.builtins import basestring
+from past.utils import old_div
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.remote.webelement import WebElement
from Selenium2Library import utils
from Selenium2Library.locators import ElementFinder
from Selenium2Library.locators import CustomLocator
-from keywordgroup import KeywordGroup
+from .keywordgroup import KeywordGroup
try:
basestring # attempt to evaluate basestring
@@ -439,8 +445,8 @@ def mouse_out(self, locator):
if element is None:
raise AssertionError("ERROR: Element %s not found." % (locator))
size = element.size
- offsetx = (size['width'] / 2) + 1
- offsety = (size['height'] / 2) + 1
+ offsetx = (old_div(size['width'], 2)) + 1
+ offsety = (old_div(size['height'], 2)) + 1
ActionChains(self._current_browser()).move_to_element(element).move_by_offset(offsetx, offsety).perform()
def mouse_over(self, locator):
diff --git a/src/Selenium2Library/keywords/_formelement.py b/src/Selenium2Library/keywords/_formelement.py
index 88a3b50ad..6e670b3fb 100644
--- a/src/Selenium2Library/keywords/_formelement.py
+++ b/src/Selenium2Library/keywords/_formelement.py
@@ -1,5 +1,6 @@
+from __future__ import absolute_import
import os
-from keywordgroup import KeywordGroup
+from .keywordgroup import KeywordGroup
from selenium.common.exceptions import WebDriverException
class _FormElementKeywords(KeywordGroup):
diff --git a/src/Selenium2Library/keywords/_javascript.py b/src/Selenium2Library/keywords/_javascript.py
index 8f68025b5..9019e74f3 100644
--- a/src/Selenium2Library/keywords/_javascript.py
+++ b/src/Selenium2Library/keywords/_javascript.py
@@ -1,5 +1,6 @@
+from __future__ import absolute_import
import os
-from keywordgroup import KeywordGroup
+from .keywordgroup import KeywordGroup
class _JavaScriptKeywords(KeywordGroup):
diff --git a/src/Selenium2Library/keywords/_logging.py b/src/Selenium2Library/keywords/_logging.py
index 4d33d2f7a..2b8a06a29 100644
--- a/src/Selenium2Library/keywords/_logging.py
+++ b/src/Selenium2Library/keywords/_logging.py
@@ -1,7 +1,8 @@
+from __future__ import absolute_import
import os
import sys
from robot.api import logger
-from keywordgroup import KeywordGroup
+from .keywordgroup import KeywordGroup
from robot.libraries.BuiltIn import BuiltIn
try:
diff --git a/src/Selenium2Library/keywords/_runonfailure.py b/src/Selenium2Library/keywords/_runonfailure.py
index 737e02f91..7cf5aa36b 100644
--- a/src/Selenium2Library/keywords/_runonfailure.py
+++ b/src/Selenium2Library/keywords/_runonfailure.py
@@ -1,5 +1,6 @@
+from __future__ import absolute_import
from robot.libraries import BuiltIn
-from keywordgroup import KeywordGroup
+from .keywordgroup import KeywordGroup
BUILTIN = BuiltIn.BuiltIn()
diff --git a/src/Selenium2Library/keywords/_screenshot.py b/src/Selenium2Library/keywords/_screenshot.py
index 8e824ccc8..7d2f6e74b 100644
--- a/src/Selenium2Library/keywords/_screenshot.py
+++ b/src/Selenium2Library/keywords/_screenshot.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
import robot
-import os, errno
+import os
+import errno
from Selenium2Library import utils
-from keywordgroup import KeywordGroup
+from .keywordgroup import KeywordGroup
class _ScreenshotKeywords(KeywordGroup):
diff --git a/src/Selenium2Library/keywords/_selectelement.py b/src/Selenium2Library/keywords/_selectelement.py
index a89553d84..be9cc7e05 100644
--- a/src/Selenium2Library/keywords/_selectelement.py
+++ b/src/Selenium2Library/keywords/_selectelement.py
@@ -1,5 +1,8 @@
+from __future__ import absolute_import
+from builtins import zip
+from builtins import range
from selenium.webdriver.support.ui import Select
-from keywordgroup import KeywordGroup
+from .keywordgroup import KeywordGroup
from selenium.common.exceptions import NoSuchElementException
diff --git a/src/Selenium2Library/keywords/_tableelement.py b/src/Selenium2Library/keywords/_tableelement.py
index 443f9eaa7..7425dd41c 100644
--- a/src/Selenium2Library/keywords/_tableelement.py
+++ b/src/Selenium2Library/keywords/_tableelement.py
@@ -1,7 +1,9 @@
+from __future__ import absolute_import
+from builtins import str
import os
import sys
from Selenium2Library.locators import TableElementFinder
-from keywordgroup import KeywordGroup
+from .keywordgroup import KeywordGroup
class _TableElementKeywords(KeywordGroup):
diff --git a/src/Selenium2Library/keywords/_waiting.py b/src/Selenium2Library/keywords/_waiting.py
index af36bc871..0183dde24 100644
--- a/src/Selenium2Library/keywords/_waiting.py
+++ b/src/Selenium2Library/keywords/_waiting.py
@@ -1,6 +1,7 @@
+from __future__ import absolute_import
import time
import robot
-from keywordgroup import KeywordGroup
+from .keywordgroup import KeywordGroup
class _WaitingKeywords(KeywordGroup):
diff --git a/src/Selenium2Library/keywords/keywordgroup.py b/src/Selenium2Library/keywords/keywordgroup.py
index dab2af51d..83ce36958 100644
--- a/src/Selenium2Library/keywords/keywordgroup.py
+++ b/src/Selenium2Library/keywords/keywordgroup.py
@@ -1,5 +1,7 @@
+from builtins import object
import sys
import inspect
+from future.utils import with_metaclass
try:
from decorator import decorator
except SyntaxError: # decorator module requires Python/Jython 2.4+
@@ -33,5 +35,5 @@ def __new__(cls, clsname, bases, dict):
dict[name] = decorator(_run_on_failure_decorator, method)
return type.__new__(cls, clsname, bases, dict)
-class KeywordGroup(object):
- __metaclass__ = KeywordGroupMetaClass
+class KeywordGroup(with_metaclass(KeywordGroupMetaClass, object)):
+ pass
diff --git a/src/Selenium2Library/locators/__init__.py b/src/Selenium2Library/locators/__init__.py
index 99bf42307..2b9aed3d4 100644
--- a/src/Selenium2Library/locators/__init__.py
+++ b/src/Selenium2Library/locators/__init__.py
@@ -1,7 +1,8 @@
-from elementfinder import ElementFinder
-from tableelementfinder import TableElementFinder
-from windowmanager import WindowManager
-from customlocator import CustomLocator
+from __future__ import absolute_import
+from .elementfinder import ElementFinder
+from .tableelementfinder import TableElementFinder
+from .windowmanager import WindowManager
+from .customlocator import CustomLocator
__all__ = [
"ElementFinder",
diff --git a/src/Selenium2Library/locators/customlocator.py b/src/Selenium2Library/locators/customlocator.py
index c7f091c39..4042cab07 100644
--- a/src/Selenium2Library/locators/customlocator.py
+++ b/src/Selenium2Library/locators/customlocator.py
@@ -1,3 +1,5 @@
+from past.builtins import basestring
+from builtins import object
from robot.libraries.BuiltIn import BuiltIn
try:
diff --git a/src/Selenium2Library/locators/elementfinder.py b/src/Selenium2Library/locators/elementfinder.py
index 6bc0496e9..be2388a2d 100644
--- a/src/Selenium2Library/locators/elementfinder.py
+++ b/src/Selenium2Library/locators/elementfinder.py
@@ -1,3 +1,4 @@
+from builtins import object
from Selenium2Library import utils
from robot.api import logger
from robot.utils import NormalizedDict
diff --git a/src/Selenium2Library/locators/tableelementfinder.py b/src/Selenium2Library/locators/tableelementfinder.py
index 91c4b97c9..10ea3d0a4 100644
--- a/src/Selenium2Library/locators/tableelementfinder.py
+++ b/src/Selenium2Library/locators/tableelementfinder.py
@@ -1,6 +1,9 @@
+from __future__ import absolute_import
+from builtins import str
+from builtins import object
from selenium.common.exceptions import NoSuchElementException
from Selenium2Library import utils
-from elementfinder import ElementFinder
+from .elementfinder import ElementFinder
class TableElementFinder(object):
@@ -91,9 +94,7 @@ def _parse_table_locator(self, table_locator, location_method):
locator_suffixes = self._locator_suffixes[(table_locator_type, location_method)]
- return map(
- lambda locator_suffix: table_locator + locator_suffix,
- locator_suffixes)
+ return [table_locator + locator_suffix for locator_suffix in locator_suffixes]
def _search_in_locators(self, browser, locators, content):
for locator in locators:
diff --git a/src/Selenium2Library/locators/windowmanager.py b/src/Selenium2Library/locators/windowmanager.py
index f7ba1ccf0..c0b5c6bfe 100644
--- a/src/Selenium2Library/locators/windowmanager.py
+++ b/src/Selenium2Library/locators/windowmanager.py
@@ -1,3 +1,4 @@
+from builtins import object
from types import *
from robot import utils
from selenium.webdriver.remote.webdriver import WebDriver
diff --git a/src/Selenium2Library/utils/__init__.py b/src/Selenium2Library/utils/__init__.py
index ec116c39d..58d9d14b5 100644
--- a/src/Selenium2Library/utils/__init__.py
+++ b/src/Selenium2Library/utils/__init__.py
@@ -1,13 +1,15 @@
-from browsercache import BrowserCache
-from librarylistener import LibraryListener
-import events
+from __future__ import absolute_import
+from builtins import str
+from .browsercache import BrowserCache
+from .librarylistener import LibraryListener
+from . import events
def escape_xpath_value(value):
- value = unicode(value)
+ value = str(value)
if '"' in value and '\'' in value:
parts_wo_apos = value.split('\'')
return "concat('%s')" % "', \"'\", '".join(parts_wo_apos)
if '\'' in value:
return "\"%s\"" % value
- return "'%s'" % value
+ return "'%s'" % value
\ No newline at end of file
diff --git a/src/Selenium2Library/utils/events/__init__.py b/src/Selenium2Library/utils/events/__init__.py
index 58da7a7b5..0c0831ea6 100644
--- a/src/Selenium2Library/utils/events/__init__.py
+++ b/src/Selenium2Library/utils/events/__init__.py
@@ -1,4 +1,5 @@
-from scope_event import ScopeStart, ScopeEnd
+from __future__ import absolute_import
+from .scope_event import ScopeStart, ScopeEnd
_registered_events = [ ScopeStart, ScopeEnd ]
_events = []
diff --git a/src/Selenium2Library/utils/events/event.py b/src/Selenium2Library/utils/events/event.py
index 17e42aabd..963c1cf09 100644
--- a/src/Selenium2Library/utils/events/event.py
+++ b/src/Selenium2Library/utils/events/event.py
@@ -1,3 +1,4 @@
+from builtins import object
import abc
class Event(object):
diff --git a/src/Selenium2Library/utils/events/scope_event.py b/src/Selenium2Library/utils/events/scope_event.py
index 5e2913221..b2c3dfdc4 100644
--- a/src/Selenium2Library/utils/events/scope_event.py
+++ b/src/Selenium2Library/utils/events/scope_event.py
@@ -1,4 +1,5 @@
-from event import Event
+from __future__ import absolute_import
+from .event import Event
from robot.libraries.BuiltIn import BuiltIn
class ScopeEvent(Event):
diff --git a/src/Selenium2Library/utils/librarylistener.py b/src/Selenium2Library/utils/librarylistener.py
index cb046145f..2727cbfae 100644
--- a/src/Selenium2Library/utils/librarylistener.py
+++ b/src/Selenium2Library/utils/librarylistener.py
@@ -1,4 +1,6 @@
-import events as event
+from __future__ import absolute_import
+from builtins import object
+from . import events as event
from robot.api import logger
class LibraryListener(object):
diff --git a/src/Selenium2Library/version.py b/src/Selenium2Library/version.py
index b0db36ef3..47fde7083 100644
--- a/src/Selenium2Library/version.py
+++ b/src/Selenium2Library/version.py
@@ -1 +1 @@
-VERSION = '1.8.1'
+VERSION = '1.8.1b1'
diff --git a/src/Selenium2Library/webdrivermonkeypatches.py b/src/Selenium2Library/webdrivermonkeypatches.py
index 53d7e7de5..dce70afb1 100644
--- a/src/Selenium2Library/webdrivermonkeypatches.py
+++ b/src/Selenium2Library/webdrivermonkeypatches.py
@@ -1,9 +1,11 @@
+from __future__ import absolute_import
+from builtins import object
import time
from robot import utils
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
-from locators import WindowManager
+from .locators import WindowManager
-class WebDriverMonkeyPatches:
+class WebDriverMonkeyPatches(object):
RemoteWebDriver._base_execute = RemoteWebDriver.execute
diff --git a/test/resources/statuschecker.py b/test/resources/statuschecker.py
index 5af72b86c..bfbc4d965 100755
--- a/test/resources/statuschecker.py
+++ b/test/resources/statuschecker.py
@@ -14,6 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import print_function
+from builtins import str
+from builtins import object
+
"""Robot Framework Test Status Checker
Usage: statuschecker.py infile [outfile]
@@ -134,7 +138,7 @@ def _check_log_message(expected, test, kw, index):
return False
-class _Expected:
+class _Expected(object):
def __init__(self, doc):
self.status, self.message = self._get_status_and_message(doc)
diff --git a/test/resources/testserver/testserver.py b/test/resources/testserver/testserver.py
index c67ca3c4a..ef1752025 100644
--- a/test/resources/testserver/testserver.py
+++ b/test/resources/testserver/testserver.py
@@ -1,12 +1,16 @@
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/336012
-import SimpleHTTPServer
-import BaseHTTPServer
-import httplib
+from __future__ import print_function
+from future import standard_library
+standard_library.install_aliases()
+
+import http.server
+import http.client
import os
+import sys
-class StoppableHttpRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+class StoppableHttpRequestHandler(http.server.SimpleHTTPRequestHandler):
"""http request handler with QUIT stopping the server"""
def do_QUIT(self):
@@ -18,7 +22,7 @@ def do_QUIT(self):
def do_POST(self):
# We could also process paremeters here using something like below.
# length = self.headers['Content-Length']
- # print self.rfile.read(int(length))
+ # print(self.rfile.read(int(length)))
self.do_GET()
def send_head(self):
@@ -51,12 +55,8 @@ def send_head(self):
else:
return self.list_directory(path)
ctype = self.guess_type(path)
- if ctype.startswith('text/'):
- mode = 'r'
- else:
- mode = 'rb'
try:
- f = open(path, mode)
+ f = open(path, 'rb')
except IOError:
self.send_error(404, "File not found")
return None
@@ -69,7 +69,7 @@ def send_head(self):
return f
-class StoppableHttpServer(BaseHTTPServer.HTTPServer):
+class StoppableHttpServer(http.server.HTTPServer):
"""http server that reacts to self.stop flag"""
def serve_forever(self):
@@ -80,21 +80,19 @@ def serve_forever(self):
def stop_server(port=7000):
"""send QUIT request to http server running on localhost:"""
- conn = httplib.HTTPConnection("localhost:%d" % port)
+ conn = http.client.HTTPConnection("localhost:%d" % port)
conn.request("QUIT", "/")
conn.getresponse()
def start_server(port=7000):
- import os
os.chdir(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), '..'))
server = StoppableHttpServer(('', port), StoppableHttpRequestHandler)
server.serve_forever()
if __name__ == '__main__':
- import sys
if len(sys.argv) != 2 or sys.argv[1] not in [ 'start', 'stop' ]:
- print('usage: %s start|stop' % sys.argv[0])
+ print("usage: {0} start|stop".format(sys.argv[0]))
sys.exit(1)
if sys.argv[1] == 'start':
start_server()
diff --git a/test/run_tests.py b/test/run_tests.py
index 4de5cf7d7..07e31aff0 100755
--- a/test/run_tests.py
+++ b/test/run_tests.py
@@ -3,10 +3,13 @@
import env
import os
import sys
+from os.path import abspath, dirname, join
from subprocess import Popen, call
from tempfile import TemporaryFile
-from run_unit_tests import run_unit_tests
+# from run_unit_tests import run_unit_tests
+
+CURDIR = dirname(abspath(__file__))
ROBOT_ARGS = [
'--doc', 'SeleniumSPacceptanceSPtestsSPwithSP%(browser)s',
@@ -37,7 +40,7 @@ def acceptance_tests(interpreter, browser, args):
ARG_VALUES['browser'] = browser.replace('*', '')
ARG_VALUES['pyVersion'] = interpreter + sys.version[:3]
start_http_server()
- runner = {'python': 'pybot', 'jython': 'jybot', 'ipy': 'ipybot'}[interpreter]
+ runner = {'python': 'robot', 'jython': 'jybot', 'ipy': 'ipybot'}[interpreter]
if os.sep == '\\':
runner += '.bat'
execute_tests(runner, args)
@@ -46,7 +49,8 @@ def acceptance_tests(interpreter, browser, args):
def start_http_server():
server_output = TemporaryFile()
- Popen(['python', env.HTTP_SERVER_FILE ,'start'],
+ python_bin = sys.executable
+ Popen([python_bin, env.HTTP_SERVER_FILE ,'start'],
stdout=server_output, stderr=server_output)
def execute_tests(runner, args):
@@ -54,28 +58,30 @@ def execute_tests(runner, args):
os.mkdir(env.RESULTS_DIR)
command = [runner] + [arg % ARG_VALUES for arg in ROBOT_ARGS] + args + [env.ACCEPTANCE_TEST_DIR]
print()
- print('Starting test execution with command:\n' + ' '.join(command))
+ print("Starting test execution with command:\n{0}".format(' '.join(command)))
syslog = os.path.join(env.RESULTS_DIR, 'syslog.txt')
call(command, shell=os.sep=='\\', env=dict(os.environ, ROBOT_SYSLOG_FILE=syslog))
def stop_http_server():
- call(['python', env.HTTP_SERVER_FILE, 'stop'])
+ python_bin = sys.executable
+ call([python_bin, env.HTTP_SERVER_FILE, 'stop'])
def process_output(args):
print()
if _has_robot_27():
- call(['python', os.path.join(env.RESOURCES_DIR, 'statuschecker.py'),
- os.path.join(env.RESULTS_DIR, 'output.xml')])
+ python_bin = sys.executable
+ call([python_bin, os.path.join(env.RESOURCES_DIR, 'statuschecker.py'),
+ os.path.join(env.RESULTS_DIR, 'output.xml')])
rebot = 'rebot' if os.sep == '/' else 'rebot.bat'
rebot_cmd = [rebot] + [ arg % ARG_VALUES for arg in REBOT_ARGS ] + args + \
[os.path.join(ARG_VALUES['outdir'], 'output.xml') ]
print()
- print('Starting output processing with command:\n' + ' '.join(rebot_cmd))
+ print("Starting output processing with command:\n{0}".format(' '.join(rebot_cmd)))
rc = call(rebot_cmd, env=os.environ)
if rc == 0:
- print('All critical tests passed')
+ print("All critical tests passed")
else:
- print('%d critical test%s failed' % (rc, 's' if rc != 1 else ''))
+ print("{0} critical test{1} failed".format(rc, 's' if rc != 1 else ''))
return rc
def _has_robot_27():
@@ -89,18 +95,19 @@ def _exit(rc):
sys.exit(rc)
def _help():
- print('Usage: python run_tests.py python|jython browser [options]')
+ print("Usage: python run_tests.py python|jython browser [options]")
print()
- print('See README.txt for details.')
+ print("See README.txt for details.")
return 255
def _run_unit_tests():
- print('Running unit tests')
- failures = run_unit_tests()
+ print("Running unit tests")
+ pypath = sys.executable
+ failures = call([pypath, os.path.join(CURDIR,'run_unit_tests.py')])
if failures != 0:
- print('\n%d unit tests failed - not running acceptance tests!' % failures)
+ print("\n{0} unit tests failed - not running acceptance tests!".format(failures))
else:
- print('All unit tests passed')
+ print("All unit tests passed")
return failures
diff --git a/test/run_unit_tests.py b/test/run_unit_tests.py
index e4cdb4fa6..64fde0b62 100755
--- a/test/run_unit_tests.py
+++ b/test/run_unit_tests.py
@@ -20,3 +20,4 @@ def run_unit_tests():
if __name__ == '__main__':
sys.exit(run_unit_tests())
+
diff --git a/test/unit/keywords/test_browsermanagement.py b/test/unit/keywords/test_browsermanagement.py
index 782491730..18fea6aee 100644
--- a/test/unit/keywords/test_browsermanagement.py
+++ b/test/unit/keywords/test_browsermanagement.py
@@ -65,10 +65,12 @@ def test_create_remote_browser_with_desired_prefs(self):
self.verify_browser(webdriver.Remote, "chrome", remote="http://127.0.0.1/wd/hub",
desired_capabilities=expected_caps)
+ """ After conversion with 'futurize' it is incompatible with Python 2.7
def test_create_remote_browser_with_string_desired_prefs(self):
expected_caps = "key1:val1,key2:val2"
self.verify_browser(webdriver.Remote, "chrome", remote="http://127.0.0.1/wd/hub",
desired_capabilities=expected_caps)
+ """
def test_capabilities_attribute_not_modified(self):
expected_caps = {"some_cap":"42"}
@@ -97,7 +99,7 @@ def test_bad_browser_name(self):
bm._make_browser("fireox")
self.fail("Exception not raised")
except ValueError as e:
- self.assertEquals("fireox is not a supported browser.", e.message)
+ self.assertEquals("fireox is not a supported browser.", "{0}".format(e))
def test_create_webdriver(self):
bm = _BrowserManagementWithLoggingStubs()
diff --git a/test/unit/utils/test_browsercache.py b/test/unit/utils/test_browsercache.py
index 50abcbd7b..cbd3fe856 100644
--- a/test/unit/utils/test_browsercache.py
+++ b/test/unit/utils/test_browsercache.py
@@ -10,7 +10,7 @@ def test_no_current_message(self):
try:
self.assertRaises(RuntimeError, cache.current.anyMember())
except RuntimeError as e:
- self.assertEqual(e.message, "No current browser")
+ self.assertEqual("{0}".format(e), "No current browser")
def test_browsers_property(self):
cache = BrowserCache()