I am using Selenium 3 with python. Currently it is possible to send a Chrome DevTools command using the execute_cdp_cmd binding:
from selenium import webdriver
driver = webdriver.Chrome()
response = driver.execute_cdp_cmd('Network.getAllCookies', {})
print(response)
Is it possible somehow to add a listener for a Network Event? Something like:
driver.execute_cdp_cmd('Network.enable')
driver.add_listener('Network.dataReceived', my_listener)
It should be natively supported in Selenium 4 (currently in alpha), but I would like to know if it is possible to make this work in Selenium 3.
I think you can't do this in Selenium 3. In Selenium 3
add_listener
doesn't look like theaddListener
in Java. Seems it only receivesConsole.ERROR
Console.ALL
andConsole.Log
as paramater.Also, this seems not to be supported in Selenium 4 so far.