45000 毫秒后,Webdriver 无法在端口 7055 上连接到主机 127.0.0.1 [英] Webdriver Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms

查看:20
本文介绍了45000 毫秒后,Webdriver 无法在端口 7055 上连接到主机 127.0.0.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有运行测试的盒子.Jenkins 似乎会通过 ssh 进入并执行正在运行的特定作业中描述的命令.

在这里,我正在尝试运行 Selenium Webdriver 测试,但它告诉我在启动 firefox 时出错.最终的想法是在这个盒子上完全运行 webtests,并截取一些错误截图.

我正在使用 selenium-java-2.25.jar、firefox 10、linux 操作系统.

有趣的是,我可以手动 ssh 进入盒子,从盒子上的另一个用户临时复制魔法 cookie(以获得 X 隧道),执行 export DISPLAY=mydisplay:1.0,然后使用 ant 启动我的 selenium 测试.这将启动 firefox 和测试.

这里有很多线程似乎有完全相同的问题,我想我已经尝试了其中的大部分.这是我所做的:

  • 重启盒子,用 VNC 重新登录.

  • 在运行 selenium 测试之前,在 Jenkins 中放置了一个 bash 脚本来运行.bash 脚本基本上只是做了一个export DISPLAY=mydisplay:1.0.它还执行 xclock.这是有效的,因为我可以看到 xclock 显示在 VNC 中.

  • iptables 已关闭

  • firefox 正确位于/usr/bin/firefox

  • sshd_config 显示 X11Forwarding 为真.

  • 据说降级firefox对一些人有帮助,但我不想这样做.无论如何,Webdriver 应该支持 FF 10.

然而,以上都不能解决问题.

似乎本地主机上的端口 7055 甚至不存在:

netstat -an |grep 7055 - 没有打印

这是我的/etc/hosts 所说的:

 1 127.0.0.1 localhost.localdomain 本地主机2 ::1 localhost6.localdomain6 localhost6

也许与 localhost:7055 不存在有关?我不确定从这里去哪里.仍然,当我指定 mydisplay:1.0 时,为什么错误输出说它正在寻找 display: :0.0 ?

最后是我收到的错误输出:

[testng] org.openqa.selenium.firefox.NotConnectedException:45000 毫秒后无法在端口 7055 上连接到主机 127.0.0.1.火狐控制台输出:[testng] Xlib:连接到:0.0"被服务器拒绝[testng] Xlib:未指定协议[测试][testng] 错误:无法打开显示:0.0[testng] Xlib:连接到:0.0"被服务器拒绝[testng] Xlib:未指定协议[测试][testng] Xlib:连接到:0.0"被服务器拒绝[testng] Xlib:未指定协议[测试][testng] Xlib:连接到:0.0"被服务器拒绝[testng] Xlib:未指定协议[测试][testng] 错误:无法打开显示:0.0[测试][testng] 在 org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:109)[testng] 在 org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:245)[testng] 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:109)[testng] 在 org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:185)[testng] 在 org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:178)[testng] 在 org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:174)[testng] 在 org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)[testng] 在 com.test.webtest.browser.BrowserFactory.createBrowser(BrowserFactory.java:24)[testng] 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[testng] 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[testng] 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[testng] 在 java.lang.reflect.Method.invoke(Method.java:601)

解决方案

不知道你是否解决了这个问题,但我刚刚从另一边解决了同样的问题.

Selenium 和 Firefox 似乎难以相互交流 - 我怀疑 Firefox 会在多个版本中进化"变化,因此无法始终保证向后和向前兼容性,并且不兼容似乎总是会产生相同的错误.

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

问题已通过从 Selenium 2.24.1 迁移到 Selenium 2.25.0 得到解决

由于 selenium 更改只是下载 jar 文件并运行它而不是旧的,因此值得尝试将此作为快速简便的故障排除程序 - 如果没有帮助,请切换回来.就您而言,我不确定要尝试使用哪个版本的 Selenium,但我认为 2.24 应该适用于 FF 10.

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

I have box where I run tests. It seems like Jenkins would ssh in and execute commands described in the specific job that's running.

Here I am trying to run my Selenium Webdriver tests, but it tells me that I have errors in launching firefox. The end idea is to run the webtests on this box entirely, and also take some screenshots of errors.

I am using selenium-java-2.25.jar, firefox 10, linux OS.

The funny thing is that I can ssh in manually into the box, temporarily copy the magic cookie from another user on the box (to get an X tunnel), do an export DISPLAY=mydisplay:1.0, then launch my selenium tests using ant. And this will bring up firefox and the tests just fine.

There are various threads here that seem to have the exact same problem, and I think I've tried most of them. Here is what I've done:

  • Reboot the box, log back in with VNC.

  • Placed a bash script in Jenkins to run before running selenium tests. The bash script basically just does an export DISPLAY=mydisplay:1.0. It also executes xclock. This works as I can see xclock being displayed in the VNC.

  • iptables have been turned off

  • firefox is correctly located in /usr/bin/firefox

  • sshd_config shows having X11Forwarding as true.

  • Supposedly downgrading firefox helped some people, but I do not wish to do this. Webdriver should support FF 10 anyway.

However, none of the above solves the problem.

It doesn't seem like port 7055 on localhost even exists:

netstat -an | grep 7055 - Nothing prints

This is what my /etc/hosts says:

  1 127.0.0.1               localhost.localdomain localhost
  2 ::1             localhost6.localdomain6 localhost6

Perhaps it has something to do with localhost:7055 not existing? I am unsure where to go from here. still, why does the error output say it's looking for display: :0.0 when I've specified mydisplay:1.0?

And finally the error output I receive:

[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)
[testng]    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:174)
[testng]    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
[testng]    at com.test.webtest.browser.BrowserFactory.createBrowser(BrowserFactory.java:24)
[testng]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[testng]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[testng]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[testng]    at java.lang.reflect.Method.invoke(Method.java:601)

解决方案

Don't know if you resolved this problem, but I have just resolved the same issue from the other side.

It appears Selenium and Firefox have difficulty talking to each other - I suspect Firefox 'evolve' changes over a number of releases, so backward and forward compatibility are not always guaranteed, and incompatibility always seems to generate the same error.

My problem started when I moved from FF 15 to FF 16. Running on Ubuntu, this happens auto magically along with other upgrades but I believe this was the critical change.

The problem was resolved by moving from Selenium 2.24.1 to Selenium 2.25.0

As the selenium change is just download the jar file and run it instead of the old one,it's worth trying this as a quick and easy troubleshooter - if it doesn't help, just switch back. In your case, I'm not sure which version of Selenium to try, but I think 2.24 should work with FF 10.

Another issue I have found in the past is that Firefox would not run as root on Ubuntu. This happens if Selenium is running as a service, or possibly if it is fired up from a bash script or cron job. This may explain why it runs for you but not for Jenkins.

这篇关于45000 毫秒后,Webdriver 无法在端口 7055 上连接到主机 127.0.0.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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