MCPcopy Index your code
hub / github.com/seleniumbase/SeleniumBase / double_click

Method double_click

seleniumbase/fixtures/base_case.py:700–778  ·  view source on GitHub ↗
(self, selector, by="css selector", timeout=None)

Source from the content-addressed store, hash-verified

698 self.click(selector, by=by, timeout=timeout, delay=0.25)
699
700 def double_click(self, selector, by="css selector", timeout=None):
701 self.__check_scope()
702 if not timeout:
703 timeout = settings.SMALL_TIMEOUT
704 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
705 timeout = self.__get_new_timeout(timeout)
706 original_selector = selector
707 original_by = by
708 selector, by = self.__recalculate_selector(selector, by)
709 element = page_actions.wait_for_element_visible(
710 self.driver,
711 selector,
712 by,
713 timeout=timeout,
714 original_selector=original_selector,
715 )
716 self.__demo_mode_highlight_if_active(original_selector, original_by)
717 if not self.demo_mode and not self.slow_mode:
718 self.__scroll_to_element(element, selector, by)
719 self.wait_for_ready_state_complete()
720 if self.__needs_minimum_wait():
721 time.sleep(0.02)
722 # Find the element one more time in case scrolling hid it
723 element = page_actions.wait_for_element_visible(
724 self.driver,
725 selector,
726 by,
727 timeout=timeout,
728 original_selector=original_selector,
729 )
730 pre_action_url = None
731 with suppress(Exception):
732 pre_action_url = self.driver.current_url
733 try:
734 if self.browser == "safari":
735 # Jump to the "except" block where the other script should work
736 raise Exception("This Exception will be caught.")
737 actions = ActionChains(self.driver)
738 actions.double_click(element).perform()
739 except Exception:
740 css_selector = self.convert_to_css_selector(selector, by=by)
741 css_selector = re.escape(css_selector) # Add "\\" to special chars
742 css_selector = self.__escape_quotes_if_needed(css_selector)
743 double_click_script = (
744 """var targetElement1 = document.querySelector('%s');
745 var clickEvent1 = document.createEvent('MouseEvents');
746 clickEvent1.initEvent('dblclick', true, true);
747 targetElement1.dispatchEvent(clickEvent1);"""
748 % css_selector
749 )
750 if ":contains\\(" not in css_selector:
751 self.execute_script(double_click_script)
752 else:
753 double_click_script = (
754 """var targetElement1 = arguments[0];
755 var clickEvent1 = document.createEvent('MouseEvents');
756 clickEvent1.initEvent('dblclick', true, true);
757 targetElement1.dispatchEvent(clickEvent1);"""

Callers 15

double_click_elementFunction · 0.80
dubbelklikMethod · 0.80
double_cliquerMethod · 0.80
doppio_clicMethod · 0.80
doble_clicMethod · 0.80
더블_클릭Method · 0.80
双击Method · 0.80
clique_duas_vezesMethod · 0.80
__click_with_offsetMethod · 0.80

Calls 15

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
__scroll_to_elementMethod · 0.95
__needs_minimum_waitMethod · 0.95
execute_scriptMethod · 0.95
wait_for_angularjsMethod · 0.95
__ad_block_as_neededMethod · 0.95