如何使用python保存使用selenium生成的日志

man*_*ngh 6 python selenium webdriver

我正在使用网络驱动程序2.20并创建了自动化套装.与selenium RC(get_log函数)不同,我无法弄清楚保存生成的日志的命令.我试过了 :

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

但是找不到python的等价物.另外http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/sel ...这也是在java中.另外我看到"导入日志记录"功能不知道如何使用它将日志保存在文件中.有什么建议 ?

Aut*_*ter 7

以下内容将为您做同样的事情.python代码没有内部日志.

from selenium import webdriver

p = webdriver.FirefoxProfile()   
p.set_preference("webdriver.log.file", "/tmp/firefox_console")
driver = webdriver.Firefox(p)
Run Code Online (Sandbox Code Playgroud)