硒服务器,硒客户端,在 UBUNTU GUI 服务器上 [英] selenium server, selenium client, on an UBUNTU GUI server
问题描述
我有一个带有 ubuntu 14.04 LTS
的 VPS
并安装了桌面包,这意味着我可以从 ssh -X
启动 firefox会议.为了进行测试,我从我的服务器启动了 selenium 独立服务器 jar (selenium-server-standalone-3.0.0-beta3.jar)
启动它后,在另一个 ssh 会话中,我只需输入 python 命令:
i have a VPS
with ubuntu 14.04 LTS
and with the desktop package installed, that mean I can launch firefox from a ssh -X
session.
To make tests, I launched from my server the selenium standalone server jar (selenium-server-standalone-3.0.0-beta3.jar)
After launching it, in another ssh session, i just enter python commands :
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
之后,按照来自http://selenium-python.readthedocs.io/getting-started.html#using-selenium-with-remote-webdriver,我输入:
And after that, following the instructions from http://selenium-python.readthedocs.io/getting-started.html#using-selenium-with-remote-webdriver, I enter :
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=DesiredCapabilities.FIREFOX)
45 秒后,我在服务器窗口和客户端窗口中都有很多错误.这是主要错误:
After 45sec, i have lots of errors in both server window and client window. Here is the main error :
引起:org.openqa.selenium.firefox.NotConnectedException:45000 毫秒后无法在端口 7055 上连接到主机 127.0.0.1.火狐控制台输出:错误:GDK_BACKEND 与可用显示不匹配
Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: Error: GDK_BACKEND does not match available displays
我看到一些人有同样的问题,但即使使用最新的 java 和 selenium 版本,我仍然遇到这个问题.预先感谢您的帮助
I saw some people with the same problem, but even with the latest java and selenium versions, i still got this issue. Thank you in advance for your help
推荐答案
您似乎正在使用最新的 firefox 版本尝试 selenium 3
.要使用 selenium 3
支持最新的 firefox,需要下载最新的 geckodriver代码>从此链接可执行
并将其解压缩到您系统中的任何位置.
It seems you're trying selenium 3
with latest firefox version. To support latest firefox with selenium 3
, need to download latest geckodriver
executable from this link and extract it into you system at any location.
现在运行 selenium-server-standalone-3.0.0-beta3.jar
使用下面的命令:-
Now to run selenium-server-standalone-3.0.0-beta3.jar
use below command :-
java -jar selenium-server-standalone-3.0.0-beta3.jar -Dwebdriver.gecko.driver = "path/to/downloaded geckodriver"
现在您需要将 marionette
属性的功能设置为 true
以支持最新的带有 selenium 3
的 firefox,如下所示:-
Now you need to set capability with marionette
property to true
to support latest firefox with selenium 3
as below :-
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
caps = DesiredCapabilities.FIREFOX
# Tell the Python bindings to use Marionette.
caps["marionette"] = True
driver = webdriver.Remote(command_executor = 'http://127.0.0.1:4444/wd/hub', desired_capabilities = caps)
注意:- 更多有关 marionette
的信息,请关注此 Mozilla
官方页面
Note :- For more information about marionette
follow this Mozilla
official page
这篇关于硒服务器,硒客户端,在 UBUNTU GUI 服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!