(self, selector="body", by="css selector", timeout=None)
| 1883 | self.__slow_mode_pause_if_active() |
| 1884 | |
| 1885 | def get_text(self, selector="body", by="css selector", timeout=None): |
| 1886 | self.__check_scope() |
| 1887 | if not timeout: |
| 1888 | timeout = settings.LARGE_TIMEOUT |
| 1889 | if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT: |
| 1890 | timeout = self.__get_new_timeout(timeout) |
| 1891 | selector, by = self.__recalculate_selector(selector, by) |
| 1892 | if self.__is_cdp_swap_needed(): |
| 1893 | return self.cdp.get_text(selector) |
| 1894 | if self.__is_shadow_selector(selector): |
| 1895 | return self.__get_shadow_text(selector, timeout) |
| 1896 | self.wait_for_ready_state_complete() |
| 1897 | time.sleep(0.01) |
| 1898 | element = page_actions.wait_for_element_visible( |
| 1899 | self.driver, selector, by, timeout |
| 1900 | ) |
| 1901 | try: |
| 1902 | element_text = element.text |
| 1903 | if self.browser == "safari": |
| 1904 | if element.tag_name.lower() in ["input", "textarea"]: |
| 1905 | element_text = element.get_attribute("value") |
| 1906 | else: |
| 1907 | element_text = element.get_attribute("innerText") |
| 1908 | elif element.tag_name.lower() in ["input", "textarea"]: |
| 1909 | element_text = element.get_property("value") |
| 1910 | except (Stale_Exception, ENI_Exception, TimeoutException): |
| 1911 | self.wait_for_ready_state_complete() |
| 1912 | time.sleep(0.14) |
| 1913 | element = page_actions.wait_for_element_visible( |
| 1914 | self.driver, selector, by, timeout |
| 1915 | ) |
| 1916 | element_text = element.text |
| 1917 | if self.browser == "safari": |
| 1918 | if element.tag_name.lower() in ["input", "textarea"]: |
| 1919 | element_text = element.get_attribute("value") |
| 1920 | else: |
| 1921 | element_text = element.get_attribute("innerText") |
| 1922 | elif element.tag_name.lower() in ["input", "textarea"]: |
| 1923 | element_text = element.get_property("value") |
| 1924 | return element_text |
| 1925 | |
| 1926 | def get_attribute( |
| 1927 | self, |
no test coverage detected