Re: Logging in selenium grid2 ?

2,923 views
Skip to first unread message

Mike Riley

unread,
Jul 3, 2012, 1:32:11 PM7/3/12
to seleniu...@googlegroups.com
To what logs are you referring to?  The ones produced by the server, or logs produced by your test code (like TestNG reports)?

Mike

On Tuesday, July 3, 2012 1:39:55 AM UTC-7, Coder wrote:
I am trying to test scripts on the nodes of selenium grid2 but I am not able to get the logs of their execution, can anybody please help me with retrieving the logs of the remote controls in selenium grid.

Thanks in advance

Coder

unread,
Jul 4, 2012, 2:23:38 AM7/4/12
to seleniu...@googlegroups.com
Hi Mike

Thanks for replying, I need the TestNg reports of the test scripts execution how do I do it using selenium grid2 can you help?

Coder

unread,
Jul 4, 2012, 3:12:44 AM7/4/12
to seleniu...@googlegroups.com

Hi Mike 

This is what I am doing

 I am using selenium grid2 to test my scripts and my problem is that I need to extract the log of the script that is executing on a particular node of the grid and for that I have written the following code

/* THIS CODE STARTS THE HUB AND ATTACHES A NODE TO THE HUB */

import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; import java.util.Map;

import org.apache.bcel.util.ClassLoader;

 import org.apache.log4j.Logger;

 import org.apache.log4j.PropertyConfigurator; 

import org.mortbay.jetty.servlet.AbstractSessionManager.Session;

 import org.openqa.grid.common.GridRole; 

import org.openqa.grid.common.RegistrationRequest;

 import org.openqa.grid.common.SeleniumProtocol;

 import org.openqa.grid.internal.utils.GridHubConfiguration;

 import org.openqa.grid.internal.utils.SelfRegisteringRemote;

 import org.openqa.grid.web.Hub;

 import org.openqa.selenium.remote.DesiredCapabilities;

 import org.openqa.selenium.server.log.LoggingManager;

 import org.seleniumhq.jetty7.util.log.LoggerLog;

 import org.testng.TestListenerAdapter;

import com.beust.testng.TestNG;

 import com.thoughtworks.selenium.Selenium; import com.thoughtworks.selenium.condition.DefaultConditionRunner.Log4jMonitor;

public class StartHubProgrammatically

 {

 Hub myHub;

 // static final Logger logger = Logger.getLogger(StartHubProgrammatically.class); 

public static void main(String s[]) throws Exception{

 StartHubProgrammatically startHub=new StartHubProgrammatically();

 startHub.startHub(); } public void startHub() throws Exception{

final Logger logger = Logger.getLogger(StartHubProgrammatically.class); PropertyConfigurator.configure("log4j.properties"); GridHubConfiguration gridHubConfig = new GridHubConfiguration(); gridHubConfig.setHost("localhost"); gridHubConfig.setPort(4444); myHub = new Hub(gridHubConfig); myHub.start();

DesiredCapabilities chrome = DesiredCapabilities.internetExplorer(); chrome.setBrowserName("*iexplore"); SelfRegisteringRemote remoteWebDriverNode = attachNodeToHub(DesiredCapabilities.internetExplorer(), GridRole.REMOTE_CONTROL, 5555, SeleniumProtocol.WebDriver);

} private SelfRegisteringRemote attachNodeToHub( DesiredCapabilities capability, GridRole role, int nodePort, SeleniumProtocol protocol) throws Exception { SelfRegisteringRemote node = null; RegistrationRequest registrationRequest = RegistrationRequest .webdriverNoCapabilities(); capability.setCapability("seleniumProtocol", protocol); registrationRequest.addDesiredCapabilitiy(capability); registrationRequest.setRole(role); registrationRequest.setConfiguration(fetchNodeConfiguration(role, nodePort, protocol)); node = new SelfRegisteringRemote(registrationRequest);

node.startRemoteServer(); node.startRegistrationProcess();

return node; }

private Map fetchNodeConfiguration(GridRole role, int portToRun, SeleniumProtocol protocol) throws MalformedURLException { Map nodeConfiguration = new HashMap(); nodeConfiguration.put(RegistrationRequest.AUTO_REGISTER, true); nodeConfiguration.put(RegistrationRequest.HUB_HOST, myHub.getHost()); nodeConfiguration.put(RegistrationRequest.HUB_PORT, myHub.getPort()); nodeConfiguration.put(RegistrationRequest.PORT, portToRun); URL remoteURL = new URL("http://" + myHub.getHost() + ":" + portToRun); nodeConfiguration.put(RegistrationRequest.PROXY_CLASS, "org.openqa.grid.selenium.proxy.WebDriverRemoteProxy"); nodeConfiguration.put(RegistrationRequest.MAX_SESSION, 1); nodeConfiguration.put(RegistrationRequest.CLEAN_UP_CYCLE, 2000); nodeConfiguration.put(RegistrationRequest.REMOTE_URL, remoteURL); nodeConfiguration.put(RegistrationRequest.MAX_INSTANCES, 1); return nodeConfiguration; }

}

/* THIS IS THE TEST SCRIPT WE EXECUTE THIS SCRIPT USING TESTNG WHICH SENDS A REQUEST ON TO THE HUB AND THE HUB ROUTES THE THIS SCRIPT TO A NODE THAT IS COMPATIBLE WITH THE CONFIGURATION SPECIFIED IN THE SCRIPT */

package com.qait.testrunner1;

import java.net.MalformedURLException; import java.net.URL;

import org.testng.annotations.*; import com.thoughtworks.selenium.DefaultSelenium; import com.thoughtworks.selenium.Selenium;

public class GridWithWebdriver {

public Selenium selenium;

@Parameters( { "browser" }) @BeforeClass public void setup(String browser) { selenium = new DefaultSelenium("localhost", 4444, browser,"http://google.com"); selenium.start(); }

@AfterClass public void tearDown() { selenium.stop(); }

@Test public void test_first() { selenium.open("/"); selenium.type("q", "First"); selenium.click("btnG"); }

@Test public void test_second() { selenium.open("/"); selenium.type("q", "second"); selenium.click("btnG"); }

}

Now the above script executes on the node of the selenium grid2 and I need to extract the logs of the script execution on the node.

We tried to use Logger to extract the logs of the nodes but what we get are the logs of the hub which is undesirable. Please suggest a way out for extracting the logs of the script executing on the node of the selenium grid. A sample code snippet will be really helpful

We referred this SO post -: How to get Test Activity Logs from Selenium Grid 2 programatically?

but in the above post the method requires a session-id attribute but we aren't able to retrieve the session id as we have made it a standalone system.


Thanks in advance


On Tuesday, 3 July 2012 23:02:11 UTC+5:30, Mike Riley wrote:

Krishnan Mahadevan

unread,
Jul 4, 2012, 3:32:37 AM7/4/12
to seleniu...@googlegroups.com

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



Have you tried WebDriver.getSessionId() and check if that works ? This method would yield the session id which is the webdriver's way of binding itself to a particular instance of a browser on a given node.
You would then couple this logic with this code snippet which basically tells you the IP and the port of the node to where your execution got routed to, by the grid. https://gist.github.com/1766772


Once you have both these information, you can do what has been suggested in the SO post which is basically do a JSON post on the grid's end-point to get all of the logs.

 

Thanks in advance


On Tuesday, 3 July 2012 23:02:11 UTC+5:30, Mike Riley wrote:
To what logs are you referring to?  The ones produced by the server, or logs produced by your test code (like TestNG reports)?

Mike

On Tuesday, July 3, 2012 1:39:55 AM UTC-7, Coder wrote:
I am trying to test scripts on the nodes of selenium grid2 but I am not able to get the logs of their execution, can anybody please help me with retrieving the logs of the remote controls in selenium grid.

Thanks in advance

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/IkHFQtQ2a2sJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.

Coder

unread,
Jul 4, 2012, 3:36:39 AM7/4/12
to seleniu...@googlegroups.com
Thanks Krishnan I am trying with what u gave me.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

Coder

unread,
Jul 4, 2012, 4:30:58 AM7/4/12
to seleniu...@googlegroups.com
Hi Krishnan,

May be our approach is wrong.Actually what we want to do is as follows:-

We want to configure a selenium grid 2 hub and attach a node to it programatically through java as I showed you in our earlier conversation.
After this I run a script using testng.Now after running the test script on a particular node having selenium server,I want to get the result in the log of a particular node in the selenium grid. I would be highly grateful to you if you can point me to a full fledged example explaining this procedure or if you can suggest some particular sequence of steps that I need to do to accomplish this.

Thanks in advance

Krishnan Mahadevan

unread,
Jul 4, 2012, 4:33:44 AM7/4/12
to seleniu...@googlegroups.com
The information that I gave you still holds valid. Be it a Grid/node setup that gets spawned via code or separately using "java -jar" the approach to get hold of the sessionid is still the same, and if the Stack Overflow suggested approach is the way of extracting the logs, then you would need to pursue what I already highlighted (You basically need to put in the separate parts together to get it to work).

I haven't tried the approach as suggested in StackOverflow yet, so I wouldn't be able to comment on it.



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Z9C0fo-TgLwJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Coder

unread,
Jul 4, 2012, 4:52:17 AM7/4/12
to seleniu...@googlegroups.com
Hi Krishnan

I sent you an invite on gtalk I would be grateful if you can accept that.

Thanks in advance

Krishnan Mahadevan

unread,
Jul 4, 2012, 4:53:26 AM7/4/12
to seleniu...@googlegroups.com
I try to restrict my gtalk contacts to a "personal" list. 

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/P008YN4hCeYJ.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Coder

unread,
Jul 4, 2012, 5:14:03 AM7/4/12
to seleniu...@googlegroups.com
Hi Krishnan yet again could you please throw some light on the code given on the following link you suggested  https://gist.github.com/1766772  how did the user get the session id in the parameter of the function actually my problem is that we are  how do we call the function you mentioned by creating a RemoteWebDriver object manually, I am not able to understand how to call this function  

 private static String[] getHostNameAndPort(String hostName, int port,SessionId session) 

the only problem is how to pass this session id.

Krishnan Mahadevan

unread,
Jul 4, 2012, 5:16:37 AM7/4/12
to seleniu...@googlegroups.com
WebDriver driver = new RemoteWebDriver(URL, dc);
//We now would have been connected to a particular node by the grid.
String[] hostAndIP = getHostNameAndPort("localhost", driver.getSessionId());

This should do the trick.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/s5XJ3m0DUd0J.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Coder

unread,
Jul 4, 2012, 5:40:13 AM7/4/12
to seleniu...@googlegroups.com
I tried the code snippet given by you above but when I write driver.getSessionId() it shows that there is no such function for the object. What can we do to remedy this problem.

Thanks in advance

Krishnan Mahadevan

unread,
Jul 4, 2012, 5:41:38 AM7/4/12
to seleniu...@googlegroups.com
Silly me !! Am terribly sorry.
Try this :

RemoteWebDriver driver = new RemoteWebDriver(URL, dc);
//We now would have been connected to a particular node by the grid.
String[] hostAndIP = getHostNameAndPort("localhost", driver.getSessionId());

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/ZsgSj3g1L8kJ.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Coder

unread,
Jul 4, 2012, 5:48:15 AM7/4/12
to seleniu...@googlegroups.com
Hi Krishanan,

Thanks but we were able to resolve the above issue but now we are getting the following exception and I am not able to understand the reason:-

[15:14:33] suvigya17: Exception in thread "main" org.openqa.selenium.WebDriverException: org.openqa.grid.internal.GridException: Empty pool of VM for setup {platform=WINDOWS, seleniumProtocol=WebDriver, ensureCleanSession=true, browserName=internet explorer, version=}

Thanks and Regards,
Coder

Krishnan Mahadevan

unread,
Jul 4, 2012, 5:49:33 AM7/4/12
to seleniu...@googlegroups.com
That is because the Grid is only running but doesnt have any nodes at all. You would need to ensure that your code to spawn the node is also executed prior to you trying to get the IP and port of your node in question.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/O88uxdLjNBYJ.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Coder

unread,
Jul 5, 2012, 1:50:11 AM7/5/12
to seleniu...@googlegroups.com
Hi Krishnan,

I tried to implement the code that you mentioned yesterday.The code is as follows:-
package com.qait.testrunner1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;

import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
import org.json.JSONException;
import org.json.JSONObject;
import org.openqa.grid.common.SeleniumProtocol;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.SessionId;

public class GridInfoExtracter{
 
public static void main(String s[]) throws MalformedURLException{
 URL url=new URL("http://localhost:4444/console");
 DesiredCapabilities capability=DesiredCapabilities.internetExplorer();
 
 capability.setBrowserName("*iexplore");
 capability.setPlatform(Platform.ANY);
 
 RemoteWebDriver webDriver=new RemoteWebDriver(url,DesiredCapabilities.internetExplorer());
 String[] hostAndIP = GridInfoExtracter.getHostNameAndPort("localhost", 4444 ,webDriver.getSessionId() );
}
 public static String[] getHostNameAndPort(String hostName, int port,
   SessionId session) {
  String[] hostAndPort = new String[2];
  String errorMsg = "Failed to acquire remote webdriver node and port info. Root cause: ";

  try {
   HttpHost host = new HttpHost(hostName, port);
   DefaultHttpClient client = new DefaultHttpClient();
   URL sessionURL = new URL("http://" + hostName + ":" + port + "/grid/api/testsession?session=" + session);
   BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", sessionURL.toExternalForm());
   HttpResponse response = client.execute(host, r);
   JSONObject object = extractObject(response);
   URL myURL = new URL(object.getString("proxyId"));
   if ((myURL.getHost() != null) && (myURL.getPort() != -1)) {
    hostAndPort[0] = myURL.getHost();
    hostAndPort[1] = Integer.toString(myURL.getPort());
   }
  } catch (Exception e) {
   
   throw new RuntimeException(errorMsg, e);
  }
  return hostAndPort;
 }

 public static JSONObject extractObject(HttpResponse resp) throws IOException, JSONException {
  BufferedReader rd = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
  StringBuffer s = new StringBuffer();
  String line;
  while ((line = rd.readLine()) != null) {
   s.append(line);
  }
  rd.close();
  JSONObject objToReturn = new JSONObject(s.toString());
  return objToReturn;
 }
}

I started the grid hub and attached a node to it through "commandprompt" but on running the code it gave the runtime exception as follows:-

Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 </title>
</head>
<body><h2>HTTP ERROR: 404</h2><pre>NOT_FOUND</pre>
<p>RequestURI=/console/session</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                

</body>
</html>

Command duration or timeout: 125 milliseconds
Build info: version: '2.17.0', revision: '15540', time: '2012-01-16 16:52:31'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_22'
Driver info: driver.version: RemoteWebDriver
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
 at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
 at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:439)
 at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:139)
 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:102)
 at com.qait.testrunner1.GridInfoExtracter.main(GridInfoExtracter.java:31)


Please help me out.

Thanks and Regards,
Coder

Krishnan Mahadevan

unread,
Jul 5, 2012, 3:23:50 AM7/5/12
to seleniu...@googlegroups.com
The same code has been running fine for me within my framework for quite sometime now. 

How are you starting the node and the hub ? 

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/kSkrALZSMK4J.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Coder

unread,
Jul 5, 2012, 3:43:52 AM7/5/12
to seleniu...@googlegroups.com
Hi Krishnan,

Actually I am starting the hub and node as follows:-

I downloaded the hub at the following location and from cmd I am executing the command as follows:-
C:\Documents and Settings\suvigya\My Documents\Downloads\selenium-grid-1.0.7-bin\selenium-grid-1.0.7>ant launch-hub

after this I executed the command for node in a new terminal as follows:-

C:\Documents and Settings\suvigya\My Documents\Downloads\selenium-grid-1.0.7-bin\selenium-grid-1.0.7>ant launch-remote-control -Denvironment="*iexplore"

and then I tried to run the code that I mentioned earlier.
Thanks,
   Coder
S

Krishnan Mahadevan

unread,
Jul 5, 2012, 3:54:00 AM7/5/12
to seleniu...@googlegroups.com
You are using Grid1. The code snippet I shared with you works only for Grid2.

Grid1 stands DEPRECATED and is currently NOT being actively maintained. You should migrate over to Grid2 (which works in backward compatibility mode as well)

Please refer below links for understanding how to work with Grid2. 


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/52HcZUi7c4gJ.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Coder

unread,
Jul 5, 2012, 4:04:45 AM7/5/12
to seleniu...@googlegroups.com
Hi Krishnan

Man I am really grateful to you for the help you are offering, I have started referring the above links and trying out the same.

Thanks
Coder

Coder

unread,
Jul 5, 2012, 5:57:11 AM7/5/12
to seleniu...@googlegroups.com
Hi Krishnan,

I started the hub and grid as you mentioned through your link. 

But now on executing the java code of extracting the IP and host that i mentioned earlier I am getting the Exception as follows:-
Exception in thread "main" org.openqa.selenium.WebDriverException: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 500 Server Error</title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /grid/register/session. Reason:
<pre>    Server Error</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
                                                
</body>
</html>

Command duration or timeout: 141 milliseconds
Build info: version: '2.17.0', revision: '15540', time: '2012-01-16 16:52:31'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_22'
Driver info: driver.version: RemoteWebDriver
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
 at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
 at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:439)
 at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:139)
 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:102)
 at com.qait.testrunner1.GridInfoExtracter.main(GridInfoExtracter.java:30)

What is the reason for the following exception.I am not able to understand.

Thanks,
Coder

Krishnan Mahadevan

unread,
Jul 5, 2012, 6:16:04 AM7/5/12
to seleniu...@googlegroups.com
Ankit,

I would need to know what is in " at com.qait.testrunner1.GridInfoExtracter.main(GridInfoExtracter.java:30)"

Is it this line that is causing the problem for you ?

RemoteWebDriver webDriver=new RemoteWebDriver(url,DesiredCapabilities.internetExplorer());

If so, then its because your URL is incorrect.

You would need to change "URL url=new URL("http://localhost:4444/console");"

into "URL url = new URL("http://localhost:4444/wd/hub");

Hopefully that should resolve your issues.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/OCLL2GVpY18J.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Coder

unread,
Jul 5, 2012, 6:39:48 AM7/5/12
to seleniu...@googlegroups.com
package com.qait.testrunner1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;

import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
import org.json.JSONException;
import org.json.JSONObject;
import org.openqa.grid.common.SeleniumProtocol;
import org.openqa.selenium.Platform;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.SessionId;

public class GridInfoExtracter{
 
public static void main(String s[]) throws MalformedURLException{
 DesiredCapabilities capabilities = new DesiredCapabilities();
 capabilities.setBrowserName("chrome");
 capabilities.setPlatform(Platform.WINDOWS);
 
 URL url = new URL("http://localhost:4444/wd/hub");
 RemoteWebDriver driver = new RemoteWebDriver(url, capabilities);
 

 String[] hostAndIP = GridInfoExtracter.getHostNameAndPort("localhost", 4444 ,driver.getSessionId() );
As told by you I manipulated the code as mentioned above and getting the following Exception :-

Exception in thread "main" org.openqa.selenium.WebDriverException: Error forwarding the new session Empty pool of VM for setup {platform=WINDOWS, browserName=*googlechrome}
Command duration or timeout: 234 milliseconds
Build info: version: '2.17.0', revision: '15540', time: '2012-01-16 16:52:31'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_22'
Driver info: driver.version: RemoteWebDriver
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
 at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
 at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:439)
 at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:139)
 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:102)
 at com.qait.testrunner1.GridInfoExtracter.main(GridInfoExtracter.java:31)
Caused by: org.openqa.grid.common.exception.GridException: Error forwarding the new session Empty pool of VM for setup {platform=WINDOWS, browserName=*googlechrome}
 at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:111)
 at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:84)
 at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:68)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
 at org.seleniumhq.jetty7.servlet.ServletHolder.handle(ServletHolder.java:565)
 at org.seleniumhq.jetty7.servlet.ServletHandler.doHandle(ServletHandler.java:479)
 at org.seleniumhq.jetty7.server.session.SessionHandler.doHandle(SessionHandler.java:225)
 at org.seleniumhq.jetty7.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
 at org.seleniumhq.jetty7.servlet.ServletHandler.doScope(ServletHandler.java:406)
 at org.seleniumhq.jetty7.server.session.SessionHandler.doScope(SessionHandler.java:186)
 at org.seleniumhq.jetty7.server.handler.ContextHandler.doScope(ContextHandler.java:965)
 at org.seleniumhq.jetty7.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
 at org.seleniumhq.jetty7.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
 at org.seleniumhq.jetty7.server.Server.handle(Server.java:349)
 at org.seleniumhq.jetty7.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
 at org.seleniumhq.jetty7.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)
 at org.seleniumhq.jetty7.server.AbstractHttpConnection.content(AbstractHttpConnection.java:894)
 at org.seleniumhq.jetty7.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:948)
 at org.seleniumhq.jetty7.http.HttpParser.parseNext(HttpParser.java:857)
 at org.seleniumhq.jetty7.http.HttpParser.parseAvailable(HttpParser.java:235)
 at org.seleniumhq.jetty7.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)
 at org.seleniumhq.jetty7.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)
 at org.seleniumhq.jetty7.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
 at org.seleniumhq.jetty7.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
 at java.lang.Thread.run(Unknown Source)

Please help me I really need this code running.

Thanks,
Coder

Krishnan Mahadevan

unread,
Jul 5, 2012, 6:46:08 AM7/5/12
to seleniu...@googlegroups.com
Ankit,

I think we already went over this error :

Exception in thread "main" org.openqa.selenium.WebDriverException: Error forwarding the new session Empty pool of VM for setup {platform=WINDOWS, browserName=*googlechrome}

This error comes up when you have just the grid running without any NODES hooked on to it.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/xH8gxqauwtIJ.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Coder

unread,
Jul 5, 2012, 7:02:29 AM7/5/12
to seleniu...@googlegroups.com
Oh I am really sorry krishnan,

Actually the exception is as follows:

Exception in thread "main" org.openqa.selenium.WebDriverException: The driver executable is a directory: C:\Grid2\chromedriver_win_20.0.1133.0
Command duration or timeout: 156 milliseconds
Build info: version: '2.17.0', revision: '15540', time: '2012-01-16 16:52:31'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_22'
Driver info: driver.version: RemoteWebDriver
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
 at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
 at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:439)
 at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:139)
 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:102)
 at com.qait.testrunner1.GridInfoExtracter.main(GridInfoExtracter.java:31)
Caused by: java.lang.IllegalStateException: The driver executable is a directory: C:\Grid2\chromedriver_win_20.0.1133.0
 at com.google.common.base.Preconditions.checkState(Preconditions.java:176)
 at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:132)
 at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:125)
 at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:61)
 at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:131)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:57)
 at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:51)
 at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:196)
 at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
 at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
 at java.util.concurrent.FutureTask.run(Unknown Source)
 at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:150)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)

I am able to understand the error but I am not able as to what changes i should make....

Please help me and really sorry to bother you.

Krishnan Mahadevan

unread,
Jul 5, 2012, 7:03:49 AM7/5/12
to seleniu...@googlegroups.com
The error is pretty straight forward

Exception in thread "main" org.openqa.selenium.WebDriverException: The driver executable is a directory: C:\Grid2\chromedriver_win_20.0.1133.0


WebDriver is telling you that the path to ChromeDriver.exe was not the exe file, but instead a directory.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/IKpGV-HAobQJ.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Coder

unread,
Jul 5, 2012, 7:43:53 AM7/5/12
to seleniu...@googlegroups.com
Krishnan

I am really very grateful and thankful to you that you helped me so much to resolve this issue that I was stuck on since yesterday now I have got the session id and I need to get the logs of the node using this session id is there any method in the selenium grid 2 api that will accomplish this for me

Thanks
Ankit Sablok

Krishnan Mahadevan

unread,
Jul 5, 2012, 8:53:18 AM7/5/12
to seleniu...@googlegroups.com
I have created a "Full fledged" working sample of how to get it done. Refer here : https://gist.github.com/3053517

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/UCEqRMrVPTMJ.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages