为了账号安全,请及时绑定邮箱和手机立即绑定

Webdriver 45000毫秒后无法连接到端口7055上的主机127.0.0.1

Webdriver 45000毫秒后无法连接到端口7055上的主机127.0.0.1

三国纷争 2019-10-08 11:19:33
我有运行测试的框。Jenkins似乎可以ssh并执行正在运行的特定作业中描述的命令。在这里,我试图运行我的Selenium Webdriver测试,但是它告诉我启动firefox时出错。最终的想法是完全在此框中运行Webtest,并拍摄一些错误屏幕截图。我正在使用selenium-java-2.25.jar,firefox 10,Linux OS。有趣的是,我可以手动插入框中,暂时将另一个用户的魔术cookie复制到框中(以获取X隧道),执行export DISPLAY=mydisplay:1.0,然后使用ant启动我的硒测试。这将带来Firefox和测试就好了。这里有各种各样的线程似乎都存在完全相同的问题,我想我已经尝试了其中的大多数。这是我所做的:重新启动该框,使用VNC重新登录。在进行硒测试之前,在Jenkins中放置了一个bash脚本以使其运行。bash脚本基本上只是执行一个export DISPLAY=mydisplay:1.0。它还执行xclock。这可以正常工作,因为我可以看到VNC中显示了xclock。iptables已关闭firefox正确位于/ usr / bin / firefox中sshd_config显示X11Forwarding为true。据说降级的Firefox帮助了一些人,但是我不希望这样做。Webdriver应该仍然支持FF 10。但是,以上均不能解决问题。似乎本地主机上的端口7055甚至不存在:netstat -an | grep 7055 -没有印这是我的/ etc / hosts所说的:  1 127.0.0.1               localhost.localdomain localhost  2 ::1             localhost6.localdomain6 localhost6也许与本地主机:7055不存在有关?我不确定从这里去哪里。仍然,为什么错误输出display: :0.0在我指定后仍显示正在寻找mydisplay:1.0?最后我收到的错误输出是:[testng] org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:[testng] Xlib: connection to ":0.0" refused by server[testng] Xlib: No protocol specified[testng] [testng] Error: cannot open display: :0.0[testng] Xlib: connection to ":0.0" refused by server[testng] Xlib: No protocol specified[testng] [testng] Xlib: connection to ":0.0" refused by server[testng] Xlib: No protocol specified[testng] [testng] Xlib: connection to ":0.0" refused by server[testng] Xlib: No protocol specified[testng] [testng] Error: cannot open display: :0.0[testng] [testng]    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:109)[testng]    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:245)[testng]    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:109)[testng]    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:185)[testng]    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:178
查看完整描述

3 回答

?
慕的地10843

TA贡献1785条经验 获得超8个赞

不知道您是否解决了这个问题,但是我刚刚从另一端解决了同样的问题。

Selenium和Firefox似乎很难互相交谈-我怀疑Firefox在多个版本上的变化都在“演变”,因此不能始终保证向后和向前的兼容性,并且不兼容似乎总是会产生相同的错误。

当我从FF 15迁移到FF 16时,我的问题就开始了。在Ubuntu上运行时,这与其他升级一样神奇地自动发生,但是我相信这是关键的变化。

通过从硒2.24.1迁移到硒2.25.0解决了该问题

由于硒的更改仅是下载jar文件并运行它而不是原来的jar文件,因此值得将其作为快速简便的疑难解答程序进行尝试-如果它无济于事,只需切换回去。就您而言,我不确定要尝试使用哪个版本的Selenium,但我认为2.24应该可以与FF 10一起使用。

我过去发现的另一个问题是,Firefox无法在Ubuntu上以root用户身份运行。如果Selenium作为服务运行,或者从bash脚本或cron作业启动,则可能会发生这种情况。这也许可以解释为什么它为您运行,而不是为詹金斯运行。


查看完整回答
反对 回复 2019-10-08
?
蝴蝶不菲

TA贡献1810条经验 获得超4个赞

我有一个类似的问题。也许这个答案也会对您有帮助。


看来您正在发生两个不同的错误:


Unable to connect to host 127.0.0.1 on port 7055

Error: no display specified

该Unable to connect错误的原因是Selenium Server的版本不知道如何使用Firefox的较新版本。您需要下载支持较新版本Firefox的Selenium Server的较新版本。


该Error: no display specified错误的原因是,正在启动Firefox,但远程主机上没有运行X服务器(GUI)。您可以使用X11转发在远程主机上运行Firefox,但将其显示在本地主机上。在Mac OS X上,您需要下载XQuartz才能使用X11转发。


查看完整回答
反对 回复 2019-10-08
  • 3 回答
  • 0 关注
  • 866 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信