(
self, selector, by="css selector", timeout=None, delay=0, scroll=True
)
| 403 | return self.get_element(url) # url is treated like a selector |
| 404 | |
| 405 | def click( |
| 406 | self, selector, by="css selector", timeout=None, delay=0, scroll=True |
| 407 | ): |
| 408 | self.__check_scope() |
| 409 | self.__skip_if_esc() |
| 410 | if not timeout: |
| 411 | timeout = settings.SMALL_TIMEOUT |
| 412 | if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT: |
| 413 | timeout = self.__get_new_timeout(timeout) |
| 414 | original_selector = selector |
| 415 | original_by = by |
| 416 | selector, by = self.__recalculate_selector(selector, by) |
| 417 | if self.__is_cdp_swap_needed(): |
| 418 | self.cdp.click(selector, timeout=timeout, scroll=scroll) |
| 419 | return |
| 420 | if delay and (type(delay) in [int, float]) and delay > 0: |
| 421 | time.sleep(delay) |
| 422 | if page_utils.is_link_text_selector(selector) or by == By.LINK_TEXT: |
| 423 | if not self.is_link_text_visible(selector): |
| 424 | # Handle a special case of links hidden in dropdowns |
| 425 | self.click_link_text(selector, timeout=timeout) |
| 426 | return |
| 427 | if ( |
| 428 | page_utils.is_partial_link_text_selector(selector) |
| 429 | or by == By.PARTIAL_LINK_TEXT |
| 430 | ): |
| 431 | if not self.is_partial_link_text_visible(selector): |
| 432 | # Handle a special case of partial links hidden in dropdowns |
| 433 | self.click_partial_link_text(selector, timeout=timeout) |
| 434 | return |
| 435 | if self.__is_shadow_selector(selector): |
| 436 | self.__shadow_click(selector, timeout) |
| 437 | return |
| 438 | if self.__needs_minimum_wait() or self.browser == "safari": |
| 439 | time.sleep(0.05) |
| 440 | element = page_actions.wait_for_element_visible( |
| 441 | self.driver, |
| 442 | selector, |
| 443 | by, |
| 444 | timeout=timeout, |
| 445 | original_selector=original_selector, |
| 446 | ) |
| 447 | self.__demo_mode_highlight_if_active(original_selector, original_by) |
| 448 | if scroll and not self.demo_mode and not self.slow_mode: |
| 449 | self.__scroll_to_element(element, selector, by) |
| 450 | pre_action_url = None |
| 451 | with suppress(Exception): |
| 452 | pre_action_url = self.driver.current_url |
| 453 | pre_window_count = len(self.driver.window_handles) |
| 454 | try: |
| 455 | if ( |
| 456 | by == By.LINK_TEXT |
| 457 | and (self.browser == "ie" or self.browser == "safari") |
| 458 | ): |
| 459 | self.__jquery_click(selector, by=by) |
| 460 | elif self.browser == "safari": |
| 461 | self.execute_script("arguments[0].click();", element) |
| 462 | else: |
no test coverage detected