Selenium Pyvirtualdisplay启动时出现卡顿问题

7

我有一个Selenium测试,想在我的Ubuntu服务器上无头运行它。它使用pyvirtualdisplay和xephyr。尽管该脚本在我的本地系统中正常运行,但在服务器上运行时会挂起。我已经尝试清空内存并重新启动服务器,但没有成功。脚本大致如下:

from selenium import webdriver
from pyvirtualdisplay import Display

display = Display(visible=0, size=(1366, 768))
display.start()
driver = webdriver.Firefox()
driver.set_window_size(1366, 768)
driver.get ("http://www.google.com/")

需要帮忙吗?

1个回答

14

好了,最终我克服了它。

sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic

sudo apt-get -y install x-ttcidfont-conf cabextract ttf-mscorefonts-installer

sudo apt-get -y install x-ttcidfont-conf

sudo dpkg-reconfigure x-ttcidfont-conf

选择了 freetype 后,当我运行 xvfb-run firefox 时,开始出现以下错误:

Xlib:  extension "RANDR" missing on display ":99".

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

(firefox:4691): LIBDBUSMENU-GLIB-WARNING **: Unable to get session bus: Error spawning command line `dbus-launch --autolaunch=c4970e12ff5496da09501f87000001fe --binary-syntax --close-stderr': Failed to execute child process "dbus-launch" (No such file or directory)

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

解决方法如下:

apt-get install dbus-x11


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接