0
votes

When does Selenium hub run one node at a time? I might be wrong around both selenium code and testNG xml.

I've configured TestNG.xml to run parallel threads and grid framework seems alright, hub active on 5555, http://xx.xx.xx.xx:5555/grid/console shows two nodes connected and active with IE browser. IE driver server is used to launch IE on both these nodes, selenium-server-standalone-2.35.0 is used for the grid on all nodes and hub. When I 'run as TestNG Test' on eclipse or through Jenkins via pom.xml, the script launches on node1 first and in the next run launches on node 2.

Could it be: 1. Wrong testNG.xml/selenium grid code? 2. Hub starts up with maxinstances=1, is this causing it? What's the solution to it? Tried using hubconfig.json but doesn't seem to take affect. 3. Any misconfiguration at nodes? 4. IEDriverServer or selenium server version issues? [tried 37/39 versions as well]..


TestNG.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="CO" verbose='1' parallel="tests" thread-count="10" preserve-order="true">

<test name="FI" preserve-order="true">
<parameter name="browser" value="internet explorer" />
<parameter name="port" value="5566" />
<classes>

<class name="src/test/java.clickonce.remoteFresh"/>

</classes>
</test> <!-- Test -->

<test name="Ad" preserve-order="true">
<parameter name="browser" value="internet explorer" />
<parameter name="port" value="5567" />

<classes>
<class name="src/test/java.clickonce.Admin"/>
</classes>
</test>
</suite> 
<!-- Suite -->

Selenium code for grid:

@BeforeTest
public void setUp() throws IOException {


    baseUrl = "http://xxx/";
    nodeUrl = "http://xx.xx.xx.xx/wd/hub";

    String sUrl = "http://xxx"; 
    DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
    capability.setBrowserName("iexplorer");
    capability.setPlatform(Platform.WINDOWS);
    capability.setCapability( InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true );
    capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);




    File file = new File("d:/IEDriverServer.exe");
    System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
    WebDriver WebDriverObj = new InternetExplorerDriver();
    WebDriverObj.get(sUrl); 

    driver = new RemoteWebDriver(new URL(nodeUrl), capability);
    selenium = new WebDriverBackedSelenium(driver, baseUrl);

}

Node commands -

java -jar selenium-server-standalone-2.35.0.jar -  Dwebdriver.ie.driver="D:\IEDriverServer.exe" -role webdriver -hub http://

xx.xx.xx.xx:5555/grid/register -port 5566 -browser "browserName=iexplorer,platform=WINDOWS"

node 2 on 5567 port

2

2 Answers

0
votes

Instead of using -role webdriver on the Node command, use -role node. Also, change the way you specify the hub and its port: change -hub http://xx.xx.xx.xx:5555/grid/register -port 5566 by -hub http://xx.xx.xx.xx/grid/register -port 5555. In the node command, you have to use the port where the hub is listening.

So, the final version of the node command will be:

java -jar selenium-server-standalone-2.35.0.jar -role node -hub http://xx.xx.xx.xx/grid/register -port 5555 -Dwebdriver.ie.driver="D:\IEDriverServer.exe"  -browser "browserName=iexplorer,platform=WINDOWS"
0
votes

Check what the user-data-dir switch is set to in the RemoteWebDriver arguments. If every time you launch you write to the same profile, you won't be able to launch 2 nodes at the same time.

    public ChromeUserImpl(URL url) {
    DesiredCapabilities cap = DesiredCapabilities.chrome();
    ChromeOptions o = new ChromeOptions();
    o.addArguments("user-data-dir=" <SHOULD BE DIFFERENT IN ORDER TO RUN SIMULATANOUSLY>);
    o.addArguments("test-type");
    o.addArguments("--start-maximized");

    cap.setCapability(ChromeOptions.CAPABILITY, o);
    mDriver = new RemoteWebDriver(url, cap);
}