简体   繁体   中英

Python Selenium : Capture Chrome Dev Tools Network Request/Response Logs using execute_cdp_cmd()

How to capture chrome.network request/response logs using selenium python execute_cdp_cmd() Here's my code

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from time import sleep

siteURL = "https://www.executeautomation.com/search"

site = webdriver.Chrome(service=Service(ChromeDriverManager().install()))

def RequestSent(**sent):
    print("SENT",sent)

def ResponseReceived(**recv):
    print("RECV",recv)

site.execute_cdp_cmd("Network.enable")
site.execute_cdp_cmd("Network.requestWillBeSent",RequestSent())
site.execute_cdp_cmd("Network.responseReceived",ResponseReceived())

site.get(siteURL)

sleep(20)

site.close()

Kindly Help! To capture chrome.network request/response logs using selenium python execute_cdp_cmd()

DevTools listening on ws://127.0.0.1:58023/devtools/browser/a6d642b0-051e-4dc9-b4af-d1d4a24de3e6

Traceback (most recent call last): File "c:\Users\user\Desktop\openia try\apideneme.py", line 18, in site.execute_cdp_cmd('Network.enable') TypeError: ChromiumDriver.execute_cdp_cmd() missing 1 required positional argument: 'cmd_args'

error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM