Update jQuery click method.
This commit is contained in:
parent
4e2c0de5f8
commit
84e4e4db1c
|
@ -352,15 +352,18 @@ class BaseCase(unittest.TestCase):
|
||||||
def jquery_click(self, selector, by=By.CSS_SELECTOR):
|
def jquery_click(self, selector, by=By.CSS_SELECTOR):
|
||||||
if selector.startswith('/') or selector.startswith('./'):
|
if selector.startswith('/') or selector.startswith('./'):
|
||||||
by = By.XPATH
|
by = By.XPATH
|
||||||
self.scroll_to(selector, by=by)
|
|
||||||
selector = self.convert_to_css_selector(selector, by=by)
|
selector = self.convert_to_css_selector(selector, by=by)
|
||||||
|
self.wait_for_element_present(
|
||||||
|
selector, by=by, timeout=settings.SMALL_TIMEOUT)
|
||||||
|
if self.is_element_visible(selector, by=by):
|
||||||
|
self._demo_mode_highlight_if_active(selector, by)
|
||||||
|
|
||||||
# Only get the first match
|
# Only get the first match
|
||||||
last_syllable = selector.split(' ')[-1]
|
last_syllable = selector.split(' ')[-1]
|
||||||
if ':' not in last_syllable:
|
if ':' not in last_syllable:
|
||||||
selector += ':first'
|
selector += ':first'
|
||||||
|
|
||||||
click_script = """jQuery('%s').click()""" % selector
|
click_script = """jQuery('%s')[0].click()""" % selector
|
||||||
try:
|
try:
|
||||||
self.execute_script(click_script)
|
self.execute_script(click_script)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in New Issue