Python脚本使用selenium firefox驱动程序在ubuntu服务器上挂起

时间:2014-06-20 11:00:18

标签: python-2.7 firefox selenium-webdriver ubuntu-13.10

我正在尝试截取一些网页的屏幕截图。我选择了selenium和firefox。我正在使用xvfb并为显示设置环境变量。

在OS X桌面上没有xvfb的情况下脚本运行正常。但是在服务器上,脚本在发出webdriver.Firefox()后挂起,好像python脚本不再执行一样。在我的进程列表中没有异常被引发并且firefox仍处于活动状态。

设定:

sudo Xvfb :10 -ac
export DISPLAY=:10

test.py

from selenium import webdriver

print 'start'
firefox = webdriver.Firefox()
print 'Hello?'
firefox.quit()
print 'done!'

输出:

start
cursor winks tauntingly

我和Chrome有同样的问题。还尝试了phantomJs闪存叉,这是成功但没有捕获闪存内容。

独立启动firefox给出

    (process:3278): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' f       failed
    Xlib:  extension "RANDR" missing on display ":10".
    Error: Access was denied while trying to open files in your profile directory.
    ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
    ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_card_driver returned     error: No such file or directory
    ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_concat returned error: No   such file or directory
    ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
    ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default

(firefox:3278): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
    //bin/dbus-launch terminated abnormally without any error message

请帮忙

谢谢!

0 个答案:

没有答案