0

Using Python and webdriver (selenium)

I need to load a web-page in webdriver and capture network traffic from it.

I have read alot of useful information by googling that helped me on the way. ie. Selenium - python. how to capture network traffic's response

I can get some of the logs, but i can not get the network-traffic-log


Basically, i do something similar to the below: (i can not show all the code here, but this basically it):

d = DesiredCapabilities.CHROME
d['goog:loggingPrefs'] = {'browser': 'ALL'}

driver = webdriver.Chrome(chrome_options=my_options,
                          executable_path=my_driver_destination,
                          desired_capabilities=d,
                          service_args=["--verbose"])

Open a webpage and perform some magic

driver.get("http://somethingsomething")

By calling get_log at this point, can i get some logs out (depending on what state my loaded page is)

logs_for_me = driver.get_log("driver")  # "performance" "browser" "server" "client"

However, i can not find any network-logs at this point (only driver and browser -logs). What am i missing ?

If i cant' get it as a parseable object, can i force the driver itself to spool the log to file so i can get it there?

  • Ok, solved it thanks to: https://stackoverflow.com/questions/52633697/selenium-python-how-to-capture-network-traffics-response?noredirect=1&lq=1 – beardswitcher Apr 29 '20 at 07:37
  • My problem was that d['goog:loggingPrefs'] = {'browser': 'ALL'} should be d['goog:loggingPrefs'] = {'performance': 'ALL'} – beardswitcher Apr 29 '20 at 08:10

0 Answers0