@@ -649,9 +649,25 @@ def add_text(self, selector, text, by="css selector", timeout=None):
649
649
if self.__is_shadow_selector(selector):
650
650
self.__shadow_type(selector, text, timeout, clear_first=False)
651
651
return
652
+ if selector == "html" and text in ["\n", Keys.ENTER, Keys.RETURN]:
653
+ # This is a shortcut for calling self.click_active_element().
654
+ # Use after "\t" or Keys.TAB to cycle through elements first.
655
+ self.click_active_element()
656
+ return
652
657
element = self.wait_for_element_visible(
653
658
selector, by=by, timeout=timeout
654
659
)
660
+ if (
661
+ selector == "html" and text.count("\t") >= 1
662
+ and text.count("\n") == 1 and text.endswith("\n")
663
+ and text.replace("\t", "").replace("\n", "").replace(" ", "") == ""
664
+ ):
665
+ # Shortcut to send multiple tabs followed by click_active_element()
666
+ self.wait_for_ready_state_complete()
667
+ for tab in range(text.count("\t")):
668
+ element.send_keys("\t")
669
+ self.click_active_element()
670
+ return
655
671
self.__demo_mode_highlight_if_active(selector, by)
656
672
if not self.demo_mode and not self.slow_mode:
657
673
self.__scroll_to_element(element, selector, by)
0 commit comments