Activate Recorder Mode on the newest tab / window.
(self)
| 5187 | self.undetectable = True |
| 5188 | |
| 5189 | def activate_recorder(self): |
| 5190 | """Activate Recorder Mode on the newest tab / window.""" |
| 5191 | from seleniumbase.js_code.recorder_js import recorder_js |
| 5192 | |
| 5193 | if not self.is_chromium(): |
| 5194 | if not is_linux: |
| 5195 | c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX |
| 5196 | c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX |
| 5197 | cr = colorama.Style.RESET_ALL |
| 5198 | sc = c1 + "Selenium" + c2 + "Base" + cr |
| 5199 | raise Exception( |
| 5200 | "The %s Recorder is for Chromium only!\n" |
| 5201 | " (Supported browsers: Chrome and Edge)" % sc |
| 5202 | ) |
| 5203 | url = self.get_current_url() |
| 5204 | if url.startswith(("data:", "about:", "chrome:", "edge:")): |
| 5205 | message = ( |
| 5206 | "The URL in Recorder-Mode cannot start with: " |
| 5207 | '"data:", "about:", "chrome:", or "edge:"!' |
| 5208 | ) |
| 5209 | print("\n" + message) |
| 5210 | return |
| 5211 | if self.recorder_ext and not self.undetectable: |
| 5212 | return # The Recorder extension is already active |
| 5213 | self.switch_to_newest_tab() |
| 5214 | with suppress(Exception): |
| 5215 | recorder_on = self.get_session_storage_item("recorder_activated") |
| 5216 | if not recorder_on == "yes": |
| 5217 | self.execute_script(recorder_js) |
| 5218 | self.recorder_mode = True |
| 5219 | message = "Recorder Mode ACTIVE. [ESC]: Pause. [~`]: Resume." |
| 5220 | print("\n" + message) |
| 5221 | p_msg = "Recorder Mode ACTIVE.<br>[ESC]: Pause. [~`]: Resume." |
| 5222 | self.post_message(p_msg, pause=False, style="error") |
| 5223 | |
| 5224 | def __current_url_is_recordable(self): |
| 5225 | url = self.get_current_url() |
no test coverage detected