import codecs
import json

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

capabilities = DesiredCapabilities.CHROME
capabilities['loggingPrefs'] = { 'browser':'ALL' }
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(desired_capabilities=capabilities, chrome_options=options)

driver.get('http://foo.com')

# print console log messages
info=[]
for entry in driver.get_log('browser'):
if entry['level']=='SEVERE':
info.append(entry)
j = json.dumps(info, indent=4,ensure_ascii=False)
with codecs.open('info.json', "w", "utf-8") as f:
f.write(j)


driver.close()

相关文章:

  • 2021-12-27
  • 2021-06-17
  • 2022-02-25
  • 2021-05-27
  • 2021-07-25
  • 2021-12-16
  • 2022-12-23
  • 2021-10-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案