How to know which node is my test running / ran on ?

463 views
Skip to first unread message

killnarendra

unread,
Dec 15, 2011, 4:14:36 PM12/15/11
to webdriver
Hello ,


We run a bunch of tests using RemoteWebDriver, Grid and MbUnit in
parallel on an array of virtual machines that we have setup.

However , sometimes the node gets orphaned , or it stops accepting
requests .

More importantly if something fails we would like to leave the browser
open and go check it. Do we have anyway of knowing in the test where
it ran ?

Thanks,
Narendra

Krishnan Mahadevan

unread,
Dec 16, 2011, 2:34:59 AM12/16/11
to webd...@googlegroups.com
This should help



public 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) {
logger.log(Level.SEVERE, errorMsg, e);
throw new RuntimeException(errorMsg, e);
}
return hostAndPort;
}

Thanks & Regards
Krishnan Mahadevan

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




--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


narendra

unread,
Dec 16, 2011, 11:39:19 AM12/16/11
to webd...@googlegroups.com
I am on version 2.9.0 and the SessionId  property is still hidden. Was this exposed in some later version ?

Thanks,
Narendra Gyanchandani
MEng CS May 2010
Cornell University
571-314-1720

narendra

unread,
Dec 16, 2011, 2:47:07 PM12/16/11
to webd...@googlegroups.com
Thanks for the reply.

As a second question , now that I have access to the sessionId , I was wondering if we could use it to reuse an existing browser session.

Do you think this can be done ?


Thanks,
Narendra Gyanchandani
MEng CS May 2010
Cornell University
571-314-1720


On Fri, Dec 16, 2011 at 2:34 AM, Krishnan Mahadevan <krishnan.ma...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages