Grind does not follow “Platform” requirements during test run

18 views
Skip to first unread message

MTOsmart MTOsmart

unread,
Jan 13, 2017, 3:15:40 PM1/13/17
to Selenium Users

i have 2 Tests in my selenium Grid on 2 different nodes. One of the nodes running MAC, another WIN.

When i specify in TestNG run both tests (for example i want to launch Win Chrome only test and MAC FF only test.)

It launch them randomly, sometimes mac will get FF another time chrome, or if win is off, it will launch both tests on mac.

When i specify in the test 

<parameter name="platform" value="WINDOWS" />

It can launch this test on the mac, and vice versa.

This s my TestNG file: 

<suite name="TestSuite" parallel="tests">


    <test name="win chrome test">
        <parameters>
            <parameter name="platform" value="WINDOWS" />
            <parameter name="browser" value="chrome" />
            <parameter name="version" value="55.0" />
            <parameter name="url" value="https://google.com" />
        </parameters>
        <classes>
            <class name="com.ParallelTest.CreateRandomProfileTest"/>
            <class name="com.ParallelTest.LogInTest">

            </class>
        </classes>
    </test>


    <test name="mac firefox test">
        <parameters>
            <parameter name="platform" value="MAC" />
            <parameter name="browser" value="firefox" />
            <parameter name="version" value="50.1.0" />
            <parameter name="url" value="https://google.com" />
        </parameters>
        <classes>
            <class name="com.ParallelTest.CreateRandomProfileTest"/>
            <class name="com.ParallelTest.LogInTest">

            </class>
        </classes>
    </test>



</suite> 

Here is my Grid Set Up file:

package com.parallelSetUp;


import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class Framework{
    String browser;
    protected WebDriver driver;

    @Parameters({ "platform","browser","version", "url" })
    @BeforeClass(alwaysRun=true)
    public void setup(String platform, String browser, String
            version, String url) throws MalformedURLException
    {
        this.browser = browser;
        driver = getDriverInstance(platform, browser, version, url);

    }

    public static WebDriver getDriverInstance(String platform, String browser, String version, String url)
            throws MalformedURLException {
        String nodeURL = "http://192.168.1.115:4444/wd/hub";
        WebDriver driver = null;
        DesiredCapabilities caps = new DesiredCapabilities();

        // Platforms
        if (platform.equalsIgnoreCase("WINDOWS")) {
            caps.setPlatform(Platform.WINDOWS);
        }
        if (platform.equalsIgnoreCase("MAC")) {
            caps.setPlatform(Platform.MAC);
        }
        if (platform.equalsIgnoreCase("ANDROID")) {
            caps.setPlatform(Platform.ANDROID);
        }

        // Browsers
        if (browser.equalsIgnoreCase("chrome")) {
            caps = DesiredCapabilities.chrome();
            //System.setProperty("webdriver.chrome.driver", "/Users/antonfiliptsov/Desktop/Grid/Chrome/ChromeDriver/chromedriver");
        }
        if (browser.equalsIgnoreCase("firefox")) {

            caps = DesiredCapabilities.firefox();
            //System.setProperty("webdriver.gecko.driver","/Users/antonfiliptsov/Desktop/Grid/Firefox/geckodriver");
        }
        if (browser.equalsIgnoreCase("safari")){
            caps = DesiredCapabilities.safari();
        }

        // Version
        caps.setVersion(version);
        driver = new RemoteWebDriver(new URL(nodeURL), caps);
        // Maximize the browser's window
         driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        // Open the Application
        driver.get(url);
        return driver;
    }

    @AfterClass
    public void afterClass() {
        driver.quit();
    }
}

And this is my Node.json

{
  "capabilities":
  [
    {
      "browserName": "firefox",
      "maxInstances": 5,
      "version": "50.1.0",
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "chrome",
      "maxInstances": 5,
      "version": "55.0",
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "safari",
      "maxInstances": 1,
      "version": "10.0.2",
      "seleniumProtocol": "WebDriver"
    }
  ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
  "maxSession": 5,
  "port": 5555,
  "register": true,
  "registerCycle": 5000,
  "hub": "http://192.168.1.115:4444",
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets" : [],
  "withoutServlets": [],
  "custom": {}
}
Reply all
Reply to author
Forward
0 new messages