Same as self.js_update_text() JavaScript + send_keys are used to update a text field. Performs self.set_value() and triggers event listeners. If text ends in "\n", set_value() presses RETURN after. Works faster than send_keys() alone due to the JS call. If not
(self, selector, text, by="css selector", timeout=None)
| 9199 | self.js_update_text(selector, text, by=by, timeout=timeout) |
| 9200 | |
| 9201 | def set_text(self, selector, text, by="css selector", timeout=None): |
| 9202 | """Same as self.js_update_text() |
| 9203 | JavaScript + send_keys are used to update a text field. |
| 9204 | Performs self.set_value() and triggers event listeners. |
| 9205 | If text ends in "\n", set_value() presses RETURN after. |
| 9206 | Works faster than send_keys() alone due to the JS call. |
| 9207 | If not an input or textarea, sets textContent instead.""" |
| 9208 | self.__check_scope() |
| 9209 | if not timeout: |
| 9210 | timeout = settings.LARGE_TIMEOUT |
| 9211 | if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT: |
| 9212 | timeout = self.__get_new_timeout(timeout) |
| 9213 | selector, by = self.__recalculate_selector(selector, by) |
| 9214 | if self.__is_cdp_swap_needed(): |
| 9215 | self.cdp.set_value(selector, text) |
| 9216 | return |
| 9217 | self.wait_for_ready_state_complete() |
| 9218 | element = page_actions.wait_for_element_present( |
| 9219 | self.driver, selector, by, timeout |
| 9220 | ) |
| 9221 | if element.tag_name.lower() in ["input", "textarea"]: |
| 9222 | self.js_update_text(selector, text, by=by, timeout=timeout) |
| 9223 | else: |
| 9224 | self.set_text_content(selector, text, by=by, timeout=timeout) |
| 9225 | |
| 9226 | def set_text_content( |
| 9227 | self, selector, text, by="css selector", timeout=None, scroll=False |
no test coverage detected