Grid problem with multiple driver instance

96 views
Skip to first unread message

Ashish Gijare

unread,
Feb 11, 2015, 1:30:58 AM2/11/15
to webd...@googlegroups.com
Hi,

I am facing a problem where i have 2 script(AutomationG1.java, AutomationG2.java) both script have 2 driver instances, Problem is when i start execution of script, driver1 of AutomationG1.java and driver3 of AutomationG2.java is executing in node1 while driver2 and driver4 is executing in Node2, here i want to run driver1 and driver2 of AutomationG1.java in node 1 and driver3 and driver4 of AutomationG2.java  in node2.

I am using POM structure, Please see attached java files and xml file.

Thanks in Advance.

Regards,
Ashish
AutomationG1.java
AutomationG2.java
DevG.xml

Krishnan Mahadevan

unread,
Feb 11, 2015, 1:32:33 AM2/11/15
to webdriver
Why does it matter to you as to which node does the Grid route your test to ? Can you please help elaborate this part ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/d/optout.

Ashish Gijare

unread,
Feb 11, 2015, 1:55:13 AM2/11/15
to webd...@googlegroups.com

Thnaks for your quick reply.Problem is driver 2 and driver 4 is doing same work I mean executing same script.while driver 2 and driver 4 should do their own work as expected in script.

--
You received this message because you are subscribed to a topic in the Google Groups "webdriver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/webdriver/aTyObVjnr0I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to webdriver+...@googlegroups.com.

Krishnan Mahadevan

unread,
Feb 11, 2015, 2:06:21 AM2/11/15
to webdriver
I didnt quite understand what you are hinting at.

How does it affect your test execution i.e., is its test results dependent on something that is specific to a node ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

Ashish Gijare

unread,
Feb 11, 2015, 2:35:48 AM2/11/15
to webd...@googlegroups.com
Yes, Is there any way  i can instruct to hub that which script should  execute on which node?

Thanks & Regards,
Ashish Gijare
+91-9871272397
Do what you love doing!!

darrell

unread,
Feb 11, 2015, 9:25:58 AM2/11/15
to webd...@googlegroups.com
When you configure a node you tell it what operating system, which version of browser, etc. These are all just key/value pairs you are setting up. You could tell the node configuration that it has the key/value pair of "node : a", "node : b", etc. Next step is when you are configuring driver1 and driver3 you tell them you want to have them setCapabilty of node=a and driver2 and driver4 setCapability to node=b. Now when driver1 or driver3 asks the hub for a node, the hub will direct them to the nodes you have configured with "node : a". When driver2 and driver4 asks the hub for a node it will direct them to the nodes configured with "node : b".

Ashish Gijare

unread,
Feb 12, 2015, 12:11:33 AM2/12/15
to webd...@googlegroups.com
Hi darrell,

Thanks for your reply, Can you Please elaborate this via code.

Ashish Gijare

unread,
Feb 12, 2015, 7:52:20 AM2/12/15
to webd...@googlegroups.com
i guess you are talking about hub and node config file, Can you please help me how can i find those file and change parameters?

Thanks for your help.

darrell

unread,
Feb 12, 2015, 9:38:09 AM2/12/15
to webd...@googlegroups.com
If you look at https://code.google.com/p/selenium/wiki/Grid2 it talks about Selenium Grid2. In this article are links to DefaultNode.json and DefaultHub.json. You can use these as a starting point. In DefaultNode.json is an array of capabilities. On of the entries looks like:

        {
          "browserName": "*firefox",
          "maxInstances": 5,
          "seleniumProtocol": "WebDriver"
        },

What you can do is change this to something like:

        {
          "browserName": "*firefox",
          "maxInstances": 5,
          "seleniumProtocol": "WebDriver",
          "node": "a"
        },

When you set up a WebDriver instance using RemoteWebDriver you can then use:

        URL url = new URL("http://localhost:4444");
        DesiredCapabilities dc = DesiredCapabilities.firefox();
        dc.setCapability("node", "a");
        WebDriver driver = new RemoteWebDriver(url, dc);

This takes DesiredCapabities.firefox() and adds the capability of "node": "a". So now if I have two nodes with node=a and two nodes with node=b, this instance of driver will only work on the nodes with "node": "a".

Ashish Gijare

unread,
Feb 12, 2015, 11:58:08 PM2/12/15
to webd...@googlegroups.com
Thanks for reply, I am trying this today.

Krishnan Mahadevan

unread,
Feb 13, 2015, 1:00:21 AM2/13/15
to webdriver
Darrell,
What you are suggesting would only work if the user is going to provide their own capability matcher.

The default capability matcher that comes packaged with Grid2 is DefaultCapabilityMatcher and it doesnt consider anything else apart from the below mentioned attributes in the Capabilities Map.

It currently only looks at the below attributes when deciding if the hub can delegate a session request to a node
1. Platform
2. BrowserName
3. Version
4. application Name.


If what you are suggesting has to work, then a user would need to plug in their own capability matcher into the grid so that this can be done.




Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Thu, Feb 12, 2015 at 8:08 PM, darrell <darrell....@gmail.com> wrote:

Ashish Gijare

unread,
Feb 13, 2015, 4:49:53 AM2/13/15
to webd...@googlegroups.com
Hi,

Now my node_config.json looks this:

{
  "capabilities":
      [
        {
          "browserName": "chrome",
          "maxInstances": 2,
 "node": "b"
        },
        {
          "browserName": "firefox",
          "maxInstances": 2
        },
        {
          "browserName": "internet explorer",
          "maxInstances": 1

        }
      ],
    "configuration":
        {
        "nodeTimeout":1200000,
        "port":5555,
 
        "hubPort":4444,
        "hubHost":"http://192.168.1.206",
 
        "nodePolling":2000,
 
        "registerCycle":10000,
        "register":true,
        "cleanUpCycle":2000,
        "timeout":50000,
        "maxSession":5,
        }
}


Command duration or timeout: 509 milliseconds
Build info: version: '2.42.0', revision: '5e824302019c86eae9c8c3ca9155e7307b410cf8', time: '2014-05-24 09:48:41'
System info: host: 'WIN-PNKGI9TOHPD', ip: '192.168.1.206', os.name: 'Windows Server 2012 R2', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_55'
Driver info: org.openqa.selenium.remote.RemoteWebDriver.

Thanks for Reply.

darrell

unread,
Feb 14, 2015, 1:26:40 AM2/14/15
to webd...@googlegroups.com
Is this something new? I set up a grid with an identifier for each node in the grid. If someone wanted to watch the browser as they ran a test they could specify the node using the setCapability, as I did in my example, and the test would only run on that specific node. No other change was needed to my framework.

I set this up in 2013 and it worked fine for me.

darrell

unread,
Feb 14, 2015, 1:31:30 AM2/14/15
to webd...@googlegroups.com
I'm not sure if it matters but you do not have the seleniumProtocol specified. It should be WebDriver. If the code defaults to seleniumProtocol set to Selenium then using WebDriver instances won't find an available node.

Krishnan Mahadevan

unread,
Feb 14, 2015, 1:34:51 AM2/14/15
to webdriver
Darrell,
Not sure about that. But looking at the code for DefaultCapabilityMatcher 

I noticed that it attempts to actually match the requested capability if it has one of those 4 attributes. In all other cases, the DefaultCapabilityMatcher always returns true.

And with respect to the protocol, yes you are right. I skipped it because Selenium protocol (Selenium 1) has already been deprecated. So no point in supporting it.




Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

Ashish Gijare

unread,
Feb 18, 2015, 2:39:26 AM2/18/15
to webd...@googlegroups.com
Hi,

I am still facing issue of timeout, i have changed timeout in node_config.json but still issue persist. Can you please help me on this issue?

Thanks for your valuable knowledge.

Marc Holden

unread,
Feb 18, 2015, 1:45:52 PM2/18/15
to webd...@googlegroups.com
Hi Ashish,

As Krishnan suggested, you should overload the applicationName property in your node_config.json file.  You can then set capability, as Darrell suggested, setting the capability name to 'applicationName', instead of 'node'.  This will give you the control you are looking for.  In our framework, this is how we control the OS version we execute against (Windows 7, XP, Windows 8, etc...).  

Can you elaborate on the timeout exception?  Error codes, stack traces, what is being attempted when the error occurs.

Hope this helps.  

-Marc
Reply all
Reply to author
Forward
0 new messages