Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Selenium2Library/keywords/_browsermanagement.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from __future__ import absolute_import
from builtins import str
import os
import robot
from robot.errors import DataError
from selenium import webdriver
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__), ".."))
Expand Down Expand Up @@ -604,7 +606,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 {})
Expand Down
17 changes: 12 additions & 5 deletions src/Selenium2Library/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
from __future__ import absolute_import
from builtins import str
import os
from fnmatch import fnmatch
from browsercache import BrowserCache
from librarylistener import LibraryListener
import events
from .browsercache import BrowserCache
from .librarylistener import LibraryListener
from . import events
from sys import version_info
if version_info[0] == 3:
levels = 0
else:
levels = -1

__all__ = [
"get_child_packages_in",
Expand Down Expand Up @@ -39,12 +46,12 @@ def get_module_names_under(root_dir, include_root_package_name=True, exclusions=

def import_modules_under(root_dir, include_root_package_name=True, exclusions=None, pattern=None):
module_names = get_module_names_under(root_dir, include_root_package_name, exclusions, pattern)
modules = [ __import__(module_name, globals(), locals(), ['*'], -1)
modules = [ __import__(module_name, globals(), locals(), ['*'], levels)
for module_name in module_names ]
return (module_names, modules)

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)
Expand Down
4 changes: 3 additions & 1 deletion test/unit/keywords/test_browsermanagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/utils/test_browsercache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down