Selenium:“已运行”无效启动服务器时出错

发布于 2024-11-04 17:28:06 字数 669 浏览 0 评论 0原文

我正在尝试启动并运行 Selenium 服务器。但是,当我输入:

java -jar selenium-server-standalone-2.0b3.jar

我收到异常:

Selenium 已经在端口 4444 上运行。或者其他一些服务正在运行。

我试图阻止它,以防万一它确实正在运行:

http://localhost :4444/selenium-server/driver/?cmd=shutDown

这让我收到消息:

错误服务器异常:sessionId 不应为 null;这个会议已经开始了吗?

如果我只是写:

http://localhost:4444/

我得到:

HTTP 错误:403
禁止代理

想法?

I am trying to get the Selenium server up and running. However, when I type:

java -jar selenium-server-standalone-2.0b3.jar

I get an Exception:

Selenium is already running on port 4444. Or some other service is.

I have tried to stop it, just in case it really is running:

http://localhost:4444/selenium-server/driver/?cmd=shutDown

That gets me the message:

ERROR Server Exception: sessionId should not be null; has this session been started yet?

If I just write:

http://localhost:4444/

I get:

HTTP ERROR: 403
Forbidden for Proxy

Ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(16

温折酒 2024-11-11 17:28:06

这对我有用:

http://localhost:4444/selenium-server/driver/? cmd=shutDownSeleniumServer

如果 selenium 服务器已经在端口 4444 上运行,那么它将关闭服务器并显示
好行
如果 selenium 没有在此端口 4444 上运行,那么通过点击上面的 url 会给你
“无法连接”

This worked for me:

http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer

If selenium server is already running on port 4444 then it will shut down the server and says
OKOK
if selenium is not running on this port 4444 then by hitting above url will give you
"Unable to connect"

十年不长 2024-11-11 17:28:06

试试这个:

lsof -i -n -P | grep 4444

杀死它所说的进程:4444

try this:

lsof -i -n -P | grep 4444

and kill the process it says is on :4444

单挑你×的.吻 2024-11-11 17:28:06

一行:

kill -9 $(lsof -ti tcp:4444)

One-liner:

kill -9 $(lsof -ti tcp:4444)

小巷里的女流氓 2024-11-11 17:28:06

Selenium 提供的错误消息有点令人困惑。它确实应该告诉您您犯了语法错误。我也有这个问题。确保 cmd 字符串完全像这样:

http://localhost:4444/selenium-server/driver/?cmd=< /a>关闭SeleniumServer


这意味着使用完整命令 shutDownSeleniumServer,并确保shut中的s 是小写的 (这是我的错误)。

希望这有帮助。

The error message Selenium offers up is a little confusing. It really should be telling you you're making a syntax error. I had this problem as well. Make sure the cmd string is PRECISELY like this:

http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer

That means using the full command shutDownSeleniumServer, and make sure the s in shut is lower-case (That was my mistake).

Hope this helps.

罪歌 2024-11-11 17:28:06

要关闭服务器,您可以使用:
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer

它会给出消息 OKOK ,意味着它已关闭。如果服务器未运行,则会显示“此网页不可用”

要检查 selenium 服务器状态,请使用此
http://localhost:4444/selenium-server/driver/?cmd=getLogMessages

如果服务器正在运行,则会显示“OK”,如果未运行,则会显示网页不可用

To shut down the server you can use:
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer

It will give message OKOK , means it got shutdown. If the server is not running then it will show "This web page not available"

To check the selenium server status , use this
http://localhost:4444/selenium-server/driver/?cmd=getLogMessages

It will give OK if server is running , if not running then it will show webpage not available

皓月长歌 2024-11-11 17:28:06

如果您使用的是 Windows,则可以打开任务管理器并找到 java.exe 或 javaw.exe 进程并将其终止。这将释放端口 4444,您应该能够重新启动 Selenium 服务器。

If you are using Windows, you can open the task manager and locate the java.exe or javaw.exe process and kill it. This will release port 4444 and you should be able to restart the Selenium server.

情徒 2024-11-11 17:28:06

我有同样的错误,但没有服务器正在运行。
排除了java版本的原因。确保您运行的是 java 7 或更高版本:

java -version

I had the same error but no server was running.
Tuned out the java version was in cause. Make sure you are running java 7 or higher:

java -version
霊感 2024-11-11 17:28:06

如果您使用 Java 启动 Selenium(而不是通过您可能使用或不使用的任何测试框架),您可以使用以下命令杀死所有剩余的 Selenium 实例:

pkill java

这保证会杀死任何 java 遗迹(包括 selenium如果以这种方式开始) - 但这里要小心 - 警告是你也可能会杀死其他进程(由于 pkill 的工作方式)。就我而言,我想杀死 JVM 中运行的任何东西,所以这为我解决了这个问题。

根据下面 Goldberg 的评论,请注意,这不会杀死系统上运行的任何驱动程序服务或浏览器!

If you started Selenium using Java (instead of via whatever testing framework you may or may not be using), you can kill all leftover Selenium instances with:

pkill java

That's guaranteed to kill any java relics (including selenium if started this way) - but be careful here - caveat is that you might be killing other procs too (due to the way pkill works). In my case, I want to kill anything running in the JVM, so this solved it for me.

As per the comment from Goldberg below, note that this will not kill any driver services or browsers running on your system!

旧情勿念 2024-11-11 17:28:06

在我的案例中,lsof 没有返回任何结果。

在 Ubuntu 机器上,我必须执行以下操作:

sudo netstat -tapen | grep ":4444 "

回复如下:

tcp6       0      0 XXXXXXXXX:4444       :::*                    LISTEN      107        31526       **10479**/java

并终止标识为 10479 的 Selenium 服务器进程(在我的情况下)

sudo kill 10479

lsof returned no results in my case.

On a Ubuntu machine I had to do the following:

sudo netstat -tapen | grep ":4444 "

Reply was like:

tcp6       0      0 XXXXXXXXX:4444       :::*                    LISTEN      107        31526       **10479**/java

And to kill the Selenium server process identified (in my case) with 10479

sudo kill 10479
审判长 2024-11-11 17:28:06

在 OSX 中,如果您遵循 @HaloWebMaster (lsof -i -n -P | grep 4444) 的命令,下一步就是获取 PID(通常是一个 4 - 5 位数字,表示进程 ID)并运行以下命令:

kill -9

您不需要 sudo,除非该进程是由其他用户或 root 启动的。

In OSX if you follow the command from @HaloWebMaster (lsof -i -n -P | grep 4444) the next step is to take the PID (usually a 4 - 5 digit number indicating the process ID) and run the following command:

kill -9 <PID>

You shouldn't need sudo unless the process was started by another user or root.

千里故人稀 2024-11-11 17:28:06

我遇到了同样的问题,我启动了 Jboss AP,在其中部署了我的应用程序,然后尝试运行 selenium 服务器但无法启动。问题是 Jboss 使用与 Selenium 服务器使用的相同端口,所以我所做的就是在不同的端口上启动 selenium 服务器

解决方案:

java -jar selenium-server-standalone-2.0b3.jar -port 1234 -htmlSuite "*firefox" "http://localhost:8080/" "path to the suite" "path to the results"

I had the same problem , I started my Jboss AP where i have my application deployed and after that tried to run the selenium server and couldn t start. The problem was that Jboss uses the same port that Selenium server uses, so what I did is to start selenium server on a different port

Solution:

java -jar selenium-server-standalone-2.0b3.jar -port 1234 -htmlSuite "*firefox" "http://localhost:8080/" "path to the suite" "path to the results"
人心善变 2024-11-11 17:28:06

对于 Windows,请尝试以下操作:

taskkill /PID; /F

For Windows, try this:

taskkill /PID <ProcessID> /F

眼泪也成诗 2024-11-11 17:28:06

如果您在 127.0.01:4444 上收到 403 错误而不是 404 错误,则表明该处正在运行某些内容。 (您确定它不可能是以前的 Selenium 实例?这是最合乎逻辑的。)

有时,Selenium 在意外退出后会继续在后台运行。我建议检查正在运行的进程,或者如果其他一切都失败则重新启动机器。

当 Hudson 要求 Selenium-Server 运行一些测试并且由于某些原因在中间失败时,我经常遇到这种情况。杀死进程就可以解决问题。

If you get a 403 error on 127.0.01:4444 and not a 404 one, something is running there. (You're positive it cannot be a previous instance Selenium ? It'd be the most logical.)

Sometimes Selenium continue running in the background after an unexpected exit. I'd suggest checking the running processes, or rebooting the machine if everything else fails.

It happens to me frequently when Hudson asks Selenium-Server to run some tests and it fails in the middle for some reasons. Killing the process solves the problem.

眼波传意 2024-11-11 17:28:06

错误服务器异常:sessionId 不应该为 null;此会话已经开始了吗? 消息来自 Selenium。如果您看到它,则表明该端口号上正在运行一个 Selenium 服务器。

That ERROR Server Exception: sessionId should not be null; has this session been started yet? message comes from Selenium. If you're seeing it, there's a Selenium server running on that port number.

旧情勿念 2024-11-11 17:28:06

如果上述所有方法都不起作用,请保存您的工作并重新启动系统。它会解决问题

If all the above is not working, please save your work and reboot your system. It will solve the problem

始终不够 2024-11-11 17:28:06

谢谢,

安德烈的链接对我来说效果很好。

由于 4444 是 Selenium 的默认端口,因此也请检查这一点。

Thanks,

The link of Andre works fine for me.

As 4444 is the default port of Selenium check this as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文