From cbb2edbea3abd41de4ea1bf0fdd2a7ef4f04f304 Mon Sep 17 00:00:00 2001 From: IlfirinPL Date: Fri, 5 Dec 2014 15:16:56 +0100 Subject: [PATCH] Update elementfinder.py to allow of use scLocator Change contains new strategies scLocator and new method _find_by_sc_locator, solution is using build into smart client function isc.AutoTest.getElement --- src/Selenium2Library/locators/elementfinder.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Selenium2Library/locators/elementfinder.py b/src/Selenium2Library/locators/elementfinder.py index a165232a5..d4b886628 100644 --- a/src/Selenium2Library/locators/elementfinder.py +++ b/src/Selenium2Library/locators/elementfinder.py @@ -18,6 +18,7 @@ def __init__(self): 'jquery': self._find_by_sizzle_selector, 'sizzle': self._find_by_sizzle_selector, 'tag': self._find_by_tag_name, + 'scLocator': self._find_by_sc_locator, 'default': self._find_by_default } self._strategies = NormalizedDict(initial=strategies, caseless=True, spaceless=True) @@ -89,6 +90,10 @@ def _find_by_tag_name(self, browser, criteria, tag, constraints): return self._filter_elements( browser.find_elements_by_tag_name(criteria), tag, constraints) + + def _find_by_sc_locator(self, browser, criteria, tag, constraints): + js = "return isc.AutoTest.getElement('%s')" % criteria.replace("'", "\\'") + return self._filter_elements([browser.execute_script(js)], tag, constraints) def _find_by_default(self, browser, criteria, tag, constraints): if criteria.startswith('//'):