I updated webdriver-manager and undetect driver because I couldn't read the entire log (only INFO level). Now I'm receiving this error that I can't explain
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: log type 'performance' not found
(Session info: chrome=114.0.5735.198)
I read other answers on Stack Overflow and I tried using:
desired_capabilities['goog:perfLoggingPrefs'] = {'enableNetwork': True}
However, with this new setting, it doesn't read any lines of the log either
import json
import time
import undetected_chromedriver as uc
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from webdriver_manager.chrome import ChromeDriverManager
class Network:
def __init__(self):
opts = uc.ChromeOptions()
opts.add_argument("--disable-blink-features=AutomationControlled")
desired_capabilities = DesiredCapabilities.CHROME
#desired_capabilities['goog:perfLoggingPrefs'] = {'enableNetwork': True}
desired_capabilities["goog:loggingPrefs"] = {"performance": "ALL"}
opts.add_argument("--ignore-certificate-errors")
opts.add_argument(f"--user-agent=Lynx: Lynx/2.8.8pre.4 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/2.12.23")
self.driver = uc.Chrome(service=Service(ChromeDriverManager().install()), options=opts,
desired_capabilities=desired_capabilities)
def get_log(self):
self.driver.get("https://streamingcommunity.codes/watch/4826")
time.sleep(15) # waiting for the page to load
for log in self.driver.get_log("performance"):
message = json.loads(log["message"])["message"]
if "Network.responseReceived" == message["method"]:
url = message['params']['response']['url']
print(url)
self.driver.quit()
network = Network()
network.get_log()
Try to set it with the ChromeOptions
opts.set_capability('goog:loggingPrefs', {'performance': 'ALL'})
self.driver = uc.Chrome(service=Service(ChromeDriverManager().install()), options=opts)
desired_capabilities
parameter is deprecated in Selenium 4 and is removed in version 4.10.