1

I am trying to get url's HTTP response of a page using selenium webdriver . Can anyone please help me with that.

I am trying to do with some code i found elsewhere

from selenium import webdriver
import logging

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

# enable browser logging
d = DesiredCapabilities.CHROME
d['loggingPrefs'] = {'performance': 'ALL'}

driver = webdriver.Chrome(executable_path="C:\\Users\\Admin\\PythonFiles\\chromedriver.exe",
                          service_args=["--verbose", "--log-path=D:\\selenium.log"],
                          desired_capabilities=d)

driver.get('https://www.atg.party')

print(driver.title)

print(driver.page_source)

performance_log = driver.get_log('performance')
print(str(performance_log).strip('[]'))

for entry in driver.get_log('performance'):
    print(entry)}

it is showing an error :

raise exception_class(message, screen, stacktrace)

    selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: log type 'performance' not found
      (Session info: chrome=77.0.3865.120)

1 Answers1

0

I had the same problem and I wanted to get the log with this method but after that, my log was not a complete network log. Based on my experience, I suggest using Browsermob like this

With using this method you can have a Har file which is a JSON-formatted archive file that has logs of a web browser's interaction with a site.

0xMax
  • 399
  • 4
  • 17