Selenium Pyvirtualdisplay在启动时挂起 [英] Selenium Pyvirtualdisplay Hangs on starting

查看:371
本文介绍了Selenium Pyvirtualdisplay在启动时挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个硒测试,我试图在我的ubuntu服务器上无头运行.它使用pyvirtualdisplay和xephyr.尽管该脚本在本地系统上运行良好,但是当我在服务器上运行该脚本时,该脚本会挂起.我试图清除内存并重新启动服务器.但是没有运气.脚本看起来像这样:

I have a selenium test which I am trying to run Headlessly on my ubuntu server. It uses pyvirtualdisplay and xephyr. Though the script is running fine in my local system, it hangs when I run it in the server. I have tried to clear memory and restarting the server. But no luck. The script looks something like this :

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/")

有帮助吗?

推荐答案

好的,最后我通过了.

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 然后我开始出现这样的错误:

chose freetype, after that, when I did xvfb-run firefox then I started getting errors like this :

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

要解决,请执行以下操作:

To resolve, do this :

apt-get install dbus-x11

这篇关于Selenium Pyvirtualdisplay在启动时挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆