Skip to content

Commit 8df51ff

Browse files
authored
Merge pull request #71 from seleniumbase/add_double_click_method
Add double click method
2 parents b93a26e + 7aa81d8 commit 8df51ff

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

help_docs/method_summary.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ self.open_url(url)
1111

1212
self.click(selector, by=By.CSS_SELECTOR, timeout=settings.SMALL_TIMEOUT)
1313

14+
self.double_click(selector, by=By.CSS_SELECTOR, timeout=settings.SMALL_TIMEOUT)
15+
1416
self.click_chain(selectors_list, by=By.CSS_SELECTOR,
1517
timeout=settings.SMALL_TIMEOUT, spacing=0)
1618

seleniumbase/fixtures/base_case.py

+21
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from seleniumbase.fixtures import xpath_to_css
3131
from selenium.webdriver.remote.webdriver import WebDriver
3232
from selenium.webdriver.common.by import By
33+
from selenium.webdriver import ActionChains
3334

3435

3536
class BaseCase(unittest.TestCase):
@@ -76,6 +77,26 @@ def click(self, selector, by=By.CSS_SELECTOR,
7677
else:
7778
self._demo_mode_pause_if_active(tiny=True)
7879

80+
def double_click(self, selector, by=By.CSS_SELECTOR,
81+
timeout=settings.SMALL_TIMEOUT):
82+
if selector.startswith('/') or selector.startswith('./'):
83+
by = By.XPATH
84+
element = page_actions.wait_for_element_visible(
85+
self.driver, selector, by, timeout=timeout)
86+
self._demo_mode_highlight_if_active(selector, by)
87+
pre_action_url = self.driver.current_url
88+
actions = ActionChains(self.driver)
89+
actions.move_to_element(element)
90+
actions.double_click(element)
91+
actions.perform()
92+
if settings.WAIT_FOR_RSC_ON_CLICKS:
93+
self.wait_for_ready_state_complete()
94+
if self.demo_mode:
95+
if self.driver.current_url != pre_action_url:
96+
self._demo_mode_pause_if_active()
97+
else:
98+
self._demo_mode_pause_if_active(tiny=True)
99+
79100
def click_chain(self, selectors_list, by=By.CSS_SELECTOR,
80101
timeout=settings.SMALL_TIMEOUT, spacing=0):
81102
""" This method clicks on a list of elements in succession.

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name='seleniumbase',
9-
version='1.2.13',
9+
version='1.2.14',
1010
url='http://seleniumbase.com',
1111
author='Michael Mintz',
1212
author_email='@mintzworld',

0 commit comments

Comments
 (0)