@@ -1251,9 +1251,17 @@ def focus(self, selector, by="css selector", timeout=None):
12511251 if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
12521252 timeout = self.__get_new_timeout(timeout)
12531253 selector, by = self.__recalculate_selector(selector, by)
1254- element = self.wait_for_element_visible (
1254+ element = self.wait_for_element_present (
12551255 selector, by=by, timeout=timeout
12561256 )
1257+ if not element.is_displayed():
1258+ css_selector = self.convert_to_css_selector(selector, by=by)
1259+ css_selector = re.escape(css_selector) # Add "\\" to special chars
1260+ css_selector = self.__escape_quotes_if_needed(css_selector)
1261+ script = """document.querySelector('%s').focus();""" % css_selector
1262+ self.execute_script(script)
1263+ self.__demo_mode_pause_if_active()
1264+ return
12571265 self.scroll_to(selector, by=by, timeout=timeout)
12581266 try:
12591267 element.send_keys(Keys.NULL)
@@ -1828,7 +1836,7 @@ def click_partial_link_text(self, partial_link_text, timeout=None):
18281836 elif self.slow_mode:
18291837 self.__slow_mode_pause_if_active()
18301838
1831- def get_text(self, selector, by="css selector", timeout=None):
1839+ def get_text(self, selector="html" , by="css selector", timeout=None):
18321840 self.__check_scope()
18331841 if not timeout:
18341842 timeout = settings.LARGE_TIMEOUT
@@ -2083,7 +2091,9 @@ def get_property(
20832091 return ""
20842092 return property_value
20852093
2086- def get_text_content(self, selector, by="css selector", timeout=None):
2094+ def get_text_content(
2095+ self, selector="html", by="css selector", timeout=None
2096+ ):
20872097 """Returns the text that appears in the HTML for an element.
20882098 This is different from "self.get_text(selector, by="css selector")"
20892099 because that only returns the visible text on a page for an element,
@@ -3401,7 +3411,7 @@ def maximize_window(self):
34013411 self.driver.maximize_window()
34023412 self.__demo_mode_pause_if_active()
34033413
3404- def switch_to_frame(self, frame, timeout=None):
3414+ def switch_to_frame(self, frame="iframe" , timeout=None):
34053415 """Wait for an iframe to appear, and switch to it. This should be
34063416 usable as a drop-in replacement for driver.switch_to.frame().
34073417 The iframe identifier can be a selector, an index, an id, a name,
@@ -6812,9 +6822,11 @@ def get_pdf_text(
68126822 try:
68136823 import cryptography
68146824 if cryptography.__version__ != "39.0.2":
6825+ del cryptography # To get newer ver
68156826 shared_utils.pip_install(
68166827 "cryptography", version="39.0.2"
68176828 )
6829+ import cryptography
68186830 except Exception:
68196831 shared_utils.pip_install(
68206832 "cryptography", version="39.0.2"
0 commit comments