vendredi 29 novembre 2019

How can I printing messages from console of Chromedriver during running code?

I have testing code and I need printing messages from driver and browser. For this I have method, but I don't how can I printing messages durinig running #test code. For test I am useing Chrome driver.

from selenium import webdriver
from termcolor import colored
import time

driver = webdriver.Chrome(path)
#d
for ansDr in driver.get_log('driver'):
    if 'INFO' in ansDr['level']:
        print(colored('INFO: ' + ansDr['message'], 'blue'))
    elif 'WARNING' in ansDr['level']:
        print(colored('WARNING: ' + ansDr['message'], 'yellow'))
    elif 'ERROR' in ansDr['level']:
        print(colored('ERROR: ',  ansDr['message'], 'red'))
    else:
        print(colored(ansDr, 'pink'))

Aucun commentaire:

Enregistrer un commentaire