Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save the logs generated using selenium with python

I am using web-driver 2.20 and created the automation suit. Unlike selenium RC (get_log function) i can't figure out the command to save the logs generated. I have tried :

FirefoxProfile p = new FirefoxProfile();   
p.setPreference("webdriver.log .file", "/tmp/firefox_console"); 
WebDriver driver = new FirefoxDriver(p); 

but can't find the python equivalent. Also http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/sel... this is also in java. Also I saw "import logging" function don't know how to save the logs in a file using it. Any suggestions ?

like image 329
mannu singh Avatar asked May 25 '12 09:05

mannu singh


People also ask

What is logging in Selenium Python?

To implement logging in Python, we have to import package logging by adding the statement import logging in our code. This is by default available with Python and we don't have to download any external plugin for that. Next we have to create an object of the logging class with the help of the getLogger method.


2 Answers

The following will do the same for you. There is no internal logs for the python code.

from selenium import webdriver

p = webdriver.FirefoxProfile()   
p.set_preference("webdriver.log.file", "/tmp/firefox_console")
driver = webdriver.Firefox(p)
like image 148
AutomatedTester Avatar answered Sep 21 '22 13:09

AutomatedTester


Thanks it worked after setting:

p.set_preference("webdriver.log.file", "/tmp/firefox_console")
like image 38
Vivek Avatar answered Sep 21 '22 13:09

Vivek