SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
347 stars 195 forks source link

Problem accessing /selenium-server/driver/ #7365

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 7365

I am trying selenium Grid on VMs with vagrant. What I did is that I followed the step
from here https://code.google.com/p/selenium/wiki/Grid2, I defined a hub:
 sudo java -jar selenium-server-standalone-2.41.0.jar -role hub

and defined the node locally on the same VM 
sudo java -jar selenium-server-standalone-2.41.0.jar -role node -hub http://10.0.2.2:4444/grid/register
in which http://10.0.2.2:4444/ is the private IP of the VM in order to register node
with hub.

My problem is that when I want to run a selenium test which is in python I get this
error:

Exception: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 500 org.openqa.grid.common.exception.GridException: Error forwarding the
new session The server returned an error : Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException:
Error while launching browser</title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /selenium-server/driver/. Reason:
<pre>    org.openqa.grid.common.exception.GridException: Error forwarding the new session
The server returned an error : Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException:
Error while launching browser</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>

I think the node cannot register to the hub, I also changed it to the public IP so
I used something like http://X.X.X.106:4444/grid/register. but I still see the error.
but when I try it outside of VM it works fine!! Any idea of how to fix selenium grid
on VM.

Reported by elaheh.esbati on 2014-05-20 11:43:38

lukeis commented 8 years ago
Am I right that the hub and the node are in different subnets?

Reported by barancev on 2014-05-20 18:33:23

lukeis commented 8 years ago
OK.

So, the issue is not related to registration of the nodes on the hub (if it was not
registered the hub would not attempt to forward requests).

The issue is that the node can't start a browser. Is the requested browser installed
on the node machine? Can you see it staring? What's on the node console, are there
any error messages there?

Reported by barancev on 2014-05-21 08:10:40

lukeis commented 8 years ago
Before I run my selenium test which is in python, When I register the node :
sudo java -jar selenium-server-standalone-2.41.0.jar -role node -hub http://X.X.X.106:4444/grid/register

I see this:

08:18:11.860 INFO - using the json request : {"class":"org.openqa.grid.common.RegistrationRequest","capabilities":[{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*firefox","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*googlechrome","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*iexplore","maxInstances":1},{"platform":"LINUX","seleniumProtocol":"WebDriver","browserName":"firefox","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"WebDriver","browserName":"chrome","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"WebDriver","browserName":"internet
explorer","maxInstances":1}],"configuration":{"port":5555,"register":true,"host":"X.X.X.106","proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy","maxSession":5,"role":"node","hubHost":"*X.X.X.106","registerCycle":5000,"hub":"http://X.X.X.106:4444/grid/register","hubPort":4444,"url":"http:/X.X.X.106:5555","remoteHost":"http://X.X.X.106:5555"
08:18:11.864 INFO - Starting auto register thread. Will try to register every 5000
ms.
08:18:11.864 INFO - Registering the node to hub :http://X.X.X.106:4444/grid/register

Which shows that the registration is done. but when I try to run my selenium test case
on the same machine, with this command: python test.py

I get this error:

<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /selenium-server/driver/. Reason:
<pre>    org.openqa.grid.common.exception.GridException: Error forwarding the new session
The server returned an error : Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException:
Error while launching browser</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>

And on the node side I get this error:

08:20:03.836 INFO - Got result: Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException:
Error while launching browser on session null

And this is the node console on the attached file

Reported by elaheh.esbati on 2014-05-21 08:26:10


lukeis commented 8 years ago
And this is the full Error after running the selenium test

ERROR: test_test2 (__main__.test2)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test2.py", line 8, in setUp
    self.selenium.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/selenium.py", line 197, in
start
    result = self.get_string("getNewBrowserSession", start_args)
  File "/usr/local/lib/python2.7/dist-packages/selenium/selenium.py", line 231, in
get_string
    result = self.do_command(verb, args)
  File "/usr/local/lib/python2.7/dist-packages/selenium/selenium.py", line 225, in
do_command
    raise Exception(data)
Exception: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 500 org.openqa.grid.common.exception.GridException: Error forwarding the
new session Empty pool of VM for setup Capabilities [{browserName=*firefox}]</title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /selenium-server/driver/. Reason:
<pre>    org.openqa.grid.common.exception.GridException: Error forwarding the new session
Empty pool of VM for setup Capabilities [{browserName=*firefox}]</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>

Reported by elaheh.esbati on 2014-05-21 08:31:33

lukeis commented 8 years ago
Run the node with -debug option and attach the log of the failure

Reported by barancev on 2014-05-21 09:14:49

lukeis commented 8 years ago
Please enclosed find the log.
I took this log before and after failing to run selenium scripts from python

Reported by elaheh.esbati on 2014-05-21 09:31:38


lukeis commented 8 years ago
28:02.707 ERROR [14] org.openqa.selenium.server.BrowserSessionFactory - Failed to start
new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Timed out waiting for profile to be created!
    at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:307)

This error means that firefox can't create a new empty profile in the tmp dir
Selnium runs a command like
/bin/firefox -profile <your tmp dir>/<random tmp profile name> 
So please check your environment to find the root cause of the failure.

Reported by barancev on 2014-05-21 09:59:17

lukeis commented 8 years ago
Hello again and thanks for your great guidance!
I checked /usr/bin/firefox and I see this error: "Error: cannot open display:0.0"

I could not still display the firefox on my vagrant after googling. 
but you think if I change this line to "chrome" instead in python testcase from selenium
IDE which is:

 self.selenium = selenium("localhost", 4444, "*chrome", "http://google.com"

does selenium support it? I get this error after running the test:

<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 500 org.openqa.grid.common.exception.GridException: Error forwarding the
new session cannot find : Capabilities [{browserName=*chrome}]</title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /selenium-server/driver/. Reason:
<pre>    org.openqa.grid.common.exception.GridException: Error forwarding the new session
cannot find : Capabilities [{browserName=*chrome}]</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>

And I was thinking only selenium IDE is compatible with firefox. Am I right?

Reported by elaheh.esbati on 2014-05-21 11:27:43

lukeis commented 8 years ago
Use xvfb to run browser in a headless environment.

Reported by barancev on 2014-05-21 11:31:04

lukeis commented 8 years ago
I could run the broswer in background and I cannot see it. But I still see the same
error when running the test.
I googled it and found this:

java -jar selenium-server-standalone-2.xx.x.jar -Dwebdriver.firefox.profile=NAME
What should I provide as the NAME parameter? I provided the path to firefox, /usr/bin/firefox.
Still the issue persisted.

Thanks!

Reported by elaheh.esbati on 2014-05-21 13:40:51

lukeis commented 8 years ago
To be honest I want to make sure that the problem is not from the node and hub side
or maybe its a common failure 
in selenium Grid that does not run the selenium scripts from python? If python caused
this failure, Should I try java instead?

Reported by elaheh.esbati on 2014-05-21 14:07:22

lukeis commented 8 years ago
Please send questions to the selenium user group [1]

[1] https://groups.google.com/forum/#!forum/selenium-users 

Reported by barancev on 2014-05-21 14:10:51

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:22:28