6

Webドライバー2.20を使用して、自動化スーツを作成しました。セレンRC(get_log関数)とは異なり、生成されたログを保存するコマンドを理解できません。私が試してみました :

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

しかし、Pythonに相当するものが見つかりません。また、 http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/sel ...これもJavaです。また、「ログのインポート」機能が、それを使用してログをファイルに保存する方法を知らないのを見ました。助言がありますか ?

4

3 に答える 3

7

以下はあなたのために同じことをします。Python コードの内部ログはありません。

from selenium import webdriver

p = webdriver.FirefoxProfile()   
p.set_preference("webdriver.log.file", "/tmp/firefox_console")
driver = webdriver.Firefox(p)
于 2012-05-25T10:05:37.080 に答える
2

設定後に機能しました:

p.set_preference("webdriver.log.file", "/tmp/firefox_console")
于 2012-05-25T11:05:50.057 に答える
0
logfile = 'logs' + os.sep + ((__file__.upper())[(__file__.rfind(os.sep)+1):]).replace('.PY', '.log')
logging.basicConfig(format= '%(asctime)-12s [%(filename)-10s] %(levelname)s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S', filename=logfile, filemode='w', level=logging.INFO)

プロジェクトワークスペースに作業可能なログファイルを作成します

于 2015-08-31T07:40:34.400 に答える