diff --git a/src/Selenium2Library/base.py b/src/Selenium2Library/base.py index 71344c0e7..07dbda94b 100644 --- a/src/Selenium2Library/base.py +++ b/src/Selenium2Library/base.py @@ -30,20 +30,16 @@ def warn(self, msg, html=False): # TODO: Move logic in elementfinder.ElementFinder but keep method as proxy # in LibraryComponent class def element_find(self, locator, first_only=True, required=True, tag=None): - if isinstance(locator, basestring): - elements = self.element_finder.find(self.browser, locator, tag) - if required and len(elements) == 0: - raise ValueError( - "Element locator '{}' did not match any elements.".format( - locator - ) - ) - if first_only: - if not elements: - return None - return elements[0] - elif isinstance(locator, WebElement): - elements = locator + if isinstance(locator, WebElement): + return locator + elements = self.element_finder.find(self.browser, locator, tag) + if required and not elements: + raise ValueError("Element locator '{}' did not match any " + "elements.".format(locator)) + if first_only: + if not elements: + return None + return elements[0] return elements # TODO: Move logic in elementfinder.ElementFinder but keep method as proxy diff --git a/src/Selenium2Library/keywords/browsermanagement.py b/src/Selenium2Library/keywords/browsermanagement.py index b23f28e02..60411d4ee 100644 --- a/src/Selenium2Library/keywords/browsermanagement.py +++ b/src/Selenium2Library/keywords/browsermanagement.py @@ -640,7 +640,7 @@ def _create_remote_web_driver(self, capabilities_type, remote_url, desired_capab desired_capabilities_object = capabilities_type.copy() - if type(desired_capabilities) in (str, unicode): + if not isinstance(desired_capabilities, dict): desired_capabilities = self._parse_capabilities_string(desired_capabilities) desired_capabilities_object.update(desired_capabilities or {}) diff --git a/src/Selenium2Library/keywords/tableelement.py b/src/Selenium2Library/keywords/tableelement.py index 5a039edb6..e9647cc34 100644 --- a/src/Selenium2Library/keywords/tableelement.py +++ b/src/Selenium2Library/keywords/tableelement.py @@ -1,5 +1,5 @@ from Selenium2Library.base import LibraryComponent -from Selenium2Library.locators.tableelementfinder import TableElementFinder +from Selenium2Library.locators import TableElementFinder from Selenium2Library.robotlibcore import keyword diff --git a/src/Selenium2Library/locators/customlocator.py b/src/Selenium2Library/locators/customlocator.py index 6f68752d7..fdf2c716e 100644 --- a/src/Selenium2Library/locators/customlocator.py +++ b/src/Selenium2Library/locators/customlocator.py @@ -1,6 +1,12 @@ from robot.libraries.BuiltIn import BuiltIn +try: + basestring +except NameError: + basestring = str + + class CustomLocator(object): def __init__(self, name, finder): diff --git a/src/Selenium2Library/locators/tableelementfinder.py b/src/Selenium2Library/locators/tableelementfinder.py index 32496c008..f12c7b028 100644 --- a/src/Selenium2Library/locators/tableelementfinder.py +++ b/src/Selenium2Library/locators/tableelementfinder.py @@ -1,6 +1,7 @@ -from .elementfinder import ElementFinder from Selenium2Library.context import ContextAware +from .elementfinder import ElementFinder + class TableElementFinder(ContextAware): diff --git a/src/Selenium2Library/utils/__init__.py b/src/Selenium2Library/utils/__init__.py index f43c24c57..4d47e3093 100644 --- a/src/Selenium2Library/utils/__init__.py +++ b/src/Selenium2Library/utils/__init__.py @@ -1,10 +1,8 @@ -from . import events from .browsercache import BrowserCache from .librarylistener import LibraryListener def escape_xpath_value(value): - value = unicode(value) if '"' in value and '\'' in value: parts_wo_apos = value.split('\'') return "concat('%s')" % "', \"'\", '".join(parts_wo_apos)