In the browser's devtools, I've make one XHR breakpoint, when the page do XHR, it will pause at the breakpoint. Then I can print some variable in the console. But when I access the same variable with selenium it throw the variable is not defind.
Is it possible to access the same context of the devtools's console in selenium.
From the console:
t
Object { type: "POST", data: '{"comm":{"cv":4747474,"ct
From the selenium:
dirver.execute_script('''console.log(t)''')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Programs\python\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 884, in execute_script
return self.execute(command, {
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Programs\python\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 430, in execute
self.error_handler.check_response(response)
File "D:\Programs\python\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: ReferenceError: t is not defined
I've another question, for now i need to manual open the devtools and manually set breakpoint after the selenium open the page. Is it possible do make it with selenium? I've search a lot, but with no result.
If I understood you right, you can store your variable inside global, so you can get it from Selenium execution context.
So your code would do smth like:
--auto-open-devtools-for-tabsargumentawaitfor it.debuggerExample: