本文介绍了在Linux上安装xvfb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让Selenium在Linux应用程序服务器上进行一些自动浏览.我被困在Selenium的"Perl录制"发送启动浏览器的请求的时刻,而独立的Selenium服务器抛出错误-超时,等待创建配置文件!".

I am trying to get Selenium to do some automated browsing on a Linux application server. I am stuck at the point where my 'perl recording' from Selenium sends a request to start the browser, and the standalone selenium server throws an error - 'Timed out waiting for profile to be created!'.

通过浏览此错误,我了解到可以通过为安装在linux服务器上的firefox浏览器创建配置文件来解决此问题.但是,当我尝试创建配置文件时,现在出现错误-

I understand from browsing this error, that I could resolve this by creating a profile for the firefox browser I installed on the linux server. However, when I try to create a profile, I now get the error -

当我查找此消息时,发现有SO帖子,建议我可以通过以下方法解决此问题:首先在服务器上安装xvfb,然后在启动Selenium服务器之前设置DISPLAY变量.但是,我不是root用户,想检查xvfb是否可以在用户的​​主目录中本地安装.

When I look this up, I find SO posts that suggest I could resolve this by installing xvfb first on the server and then setting the DISPLAY variable before starting the selenium server. However, I am not a root user, and wanted to check if xvfb can be installed locally on a user's home directory.

推荐答案

首先需要安装 X窗口系统框架缓冲区x服务器:

yum install xorg-x11-server-Xvfb.x86_64

确保已安装Firefox,然后在某些显示端口(如99)上启动x服务器

make sure you have firefox installed, then start the x server on some display port like 99

Xvfb :99 -ac -screen 0 1280x1024x24 &

通过在代码或bash配置文件中导出DISPLAY =:99,将DISPLAY环境设置为99.

Set the DISPLAY environment to 99 by export DISPLAY=:99 in your code or maybe in bash profile.

这篇关于在Linux上安装xvfb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 21:30