| 1084 | self.loop.run_until_complete(self.page.evaluate(js_code)) |
| 1085 | |
| 1086 | def send_keys(self, selector, text, timeout=None): |
| 1087 | if not timeout: |
| 1088 | timeout = settings.SMALL_TIMEOUT |
| 1089 | self.__slow_mode_pause_if_set() |
| 1090 | element = self.select(selector, timeout=timeout) |
| 1091 | element.scroll_into_view() |
| 1092 | if text.endswith("\n") or text.endswith("\r"): |
| 1093 | text = text[:-1] + "\r\n" |
| 1094 | elif ( |
| 1095 | element.tag_name == "textarea" |
| 1096 | and "\n" in text |
| 1097 | and "\r" not in text |
| 1098 | ): |
| 1099 | text = text.replace("\n", "\r") |
| 1100 | element.send_keys(text) |
| 1101 | self.__slow_mode_pause_if_set() |
| 1102 | self.loop.run_until_complete(self.page.sleep(0.025)) |
| 1103 | |
| 1104 | def press_keys(self, selector, text, timeout=None): |
| 1105 | """Similar to send_keys(), but presses keys at human speed.""" |