| 240 | self.driver.get(self.url) |
| 241 | |
| 242 | def execute_python(self, code, wait_for_terminate=True): |
| 243 | if wait_for_terminate: |
| 244 | self.driver.execute_async_script( |
| 245 | f""" |
| 246 | let callback = arguments[arguments.length-1]; |
| 247 | python = `{code}`; |
| 248 | window.python_done_callback = callback; |
| 249 | window.pyworker.postMessage( |
| 250 | {{python, isatty: {'true' if sys.stdout.isatty() else 'false'}}}); |
| 251 | """ |
| 252 | ) |
| 253 | else: |
| 254 | self.driver.execute_script( |
| 255 | f""" |
| 256 | let python = `{code}`; |
| 257 | window.python_done_callback= (x) => {{window.python_script_done=x;}}; |
| 258 | window.pyworker.postMessage( |
| 259 | {{python,isatty:{'true' if sys.stdout.isatty() else 'false'}}}); |
| 260 | """ |
| 261 | ) |
| 262 | |
| 263 | def clear_logs(self): |
| 264 | self.driver.execute_script("window.python_logs = [];") |