Selenium:“已运行”无效启动服务器时出错
我正在尝试启动并运行 Selenium 服务器。但是,当我输入:
java -jar selenium-server-standalone-2.0b3.jar
我收到异常:
Selenium 已经在端口 4444 上运行。或者其他一些服务正在运行。
我试图阻止它,以防万一它确实正在运行:
http://localhost :4444/selenium-server/driver/?cmd=shutDown
这让我收到消息:
错误服务器异常:sessionId 不应为 null;这个会议已经开始了吗?
如果我只是写:
我得到:
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:
I get:
HTTP ERROR: 403
Forbidden for Proxy
Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
这对我有用:
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"
试试这个:
并
杀死
它所说的进程:4444try this:
and
kill
the process it says is on :4444一行:
kill -9 $(lsof -ti tcp:4444)
One-liner:
kill -9 $(lsof -ti tcp:4444)
Selenium 提供的错误消息有点令人困惑。它确实应该告诉您您犯了语法错误。我也有这个问题。确保 cmd 字符串完全像这样:
这意味着使用完整命令
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:
That means using the full command
shutDownSeleniumServer
, and make sure thes
inshut
is lower-case (That was my mistake).Hope this helps.
要关闭服务器,您可以使用:
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
如果您使用的是 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.
我有同样的错误,但没有服务器正在运行。
排除了java版本的原因。确保您运行的是 java 7 或更高版本:
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 启动 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!
在我的案例中,
lsof
没有返回任何结果。在 Ubuntu 机器上,我必须执行以下操作:
回复如下:
并终止标识为 10479 的 Selenium 服务器进程(在我的情况下)
lsof
returned no results in my case.On a Ubuntu machine I had to do the following:
Reply was like:
And to kill the Selenium server process identified (in my case) with 10479
在 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.
我遇到了同样的问题,我启动了 Jboss AP,在其中部署了我的应用程序,然后尝试运行 selenium 服务器但无法启动。问题是 Jboss 使用与 Selenium 服务器使用的相同端口,所以我所做的就是在不同的端口上启动 selenium 服务器
解决方案:
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:
对于 Windows,请尝试以下操作:
taskkill /PID; /F
For Windows, try this:
taskkill /PID <ProcessID> /F
如果您在 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.
错误服务器异常: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.如果上述所有方法都不起作用,请保存您的工作并重新启动系统。它会解决问题
If all the above is not working, please save your work and reboot your system. It will solve the problem
谢谢,
安德烈的链接对我来说效果很好。
由于 4444 是 Selenium 的默认端口,因此也请检查这一点。
Thanks,
The link of Andre works fine for me.
As 4444 is the default port of Selenium check this as well.