我有一个代码,据了解,它应该收集3个日志级别为警告的日志文件,但应收集25个级别信息的日志文件。我怎么可能在哪里堆叠?
mail_url = 'https://mail.yandex.ru'
caps = DesiredCapabilities.CHROME
caps['loggingPrefs'] = {'performance': 'WARNING'}
driver = webdriver.Chrome(desired_capabilities=caps)
def get_log():
for entry in driver.get_log('performance'):
date_stamp = str(datetime.datetime.now()).split('.')[0]
date_stamp = date_stamp.replace(" ", "_").replace(":", "_").replace("-", "_")
fileVar = open("log_" + date_stamp + ".txt", "w")
fileVar.write(str(entry))
fileVar.close()
def take_screenshot():
date_stamp = str(datetime.datetime.now()).split('.')[0]
date_stamp = date_stamp.replace(" ", "_").replace(":", "_").replace("-", "_")
driver.save_screenshot(date_stamp + ".png")
driver.set_window_size(360, 740) #open ya.ru in 360x740
driver.get('https://ya.ru')
time.sleep (5)
get_log()
driver.set_window_size(1920, 1080) #open ya.ru in 1920x1080
driver.get('https://ya.ru')
time.sleep (5)
get_log()
target = driver.find_element_by_xpath('//a[@href="' + mail_url + '"]')
builder = ActionChains(driver)
builder.move_to_element(target).perform()
get_log()
driver.set_window_size(800, 600)
答案 0 :(得分:1)
loggingPrefs
键应该是browser
,而不是performance
caps['loggingPrefs'] = {'browser': 'WARNING'}
driver = webdriver.Chrome(desired_capabilities=caps)
for entry in driver.get_log('browser'):
# ...