How to run a Single test case on More than one Remote Machine ??

Hi All

I am able to run a test case on multiple browser after learning this from “ToolsQA” site. But i am little confuse in configuration of multiple Remote machine.

Could you please tell me how to run a test case on multiple Remote machine.

FYI: I am able to configure Hub and node hierarchy as one hub with multiple nodes.
I am confused on Parametrization of TestNG framework as well as Test case to handle this

nagesh1312 Default Asked on March 24, 2015 in Selenium WebDriver.
Add Comment
2 Answer(s)

Nagesh,

It quite hard to undertsand your problem without seeing relevant part of your code. But from what I can gather from your explaination this what I can suggest

A Grid runs tests on machines based on the configurations of RemoteWebDriver that you have created. Grid will run the test on the machine which matches the Remote machines configuration.

The problem can be reduced to two steps
1. Create remoteWebDrivers with different configurations.
2. Pass these different remote webdrivers again and again to the same test or set of multiple tests

Step 1: Can be achieved by using a DataProvider which providers multiple remoteWebdrivers.
Step 2″:  If you use a DataProvider which provides multiple sets of RemoteWebDriver your tests will be run in loop for all the remote driver configurations.

If you are not able to to code this do let me know, I will try to put some coded example here

Virender

Virender Singh Professor Answered on March 25, 2015.
Add Comment

package Automation;

import org.testng.annotations.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;

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

public class NewTest1
{
public WebDriver driver;
public String URL, Node;
protected ThreadLocal<RemoteWebDriver> threadDriver = null;

@Parameters(“browser”)
@BeforeTest
public void launchapp(String browser) throws MalformedURLException
{
String URL = “http://www.google.com/”;

if (browser.equalsIgnoreCase(“firefox”))
{
System.out.println(” Executing on FireFox”);
String Node = “http://10.80.1.113:5559/wd/hub”;
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setBrowserName(“firefox”);

driver = new RemoteWebDriver(new URL(Node), cap);
// Puts an Implicit wait, Will wait for 10 seconds before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

// Launch website
driver.navigate().to(URL);
driver.manage().window().maximize();
}

else if (browser.equalsIgnoreCase(“chrome”))
{
System.out.println(” Executing on CHROME”);
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setBrowserName(“chrome”);
String Node = “http://10.80.1.113:5558:5557/wd/hub”;
driver = new RemoteWebDriver(new URL(Node), cap);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

// Launch website
driver.navigate().to(URL);
driver.manage().window().maximize();
}
else if (browser.equalsIgnoreCase(“ie”))
{System.out.println(” Executing on IE”);
DesiredCapabilities cap = DesiredCapabilities.internetExplorer();
cap.setBrowserName(“ie”);
String Node1 = “http://10.80.1.131:5558/wd/hub”;
driver = new RemoteWebDriver(new URL(Node1), cap);

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

driver.navigate().to(URL);
driver.manage().window().maximize();
}
else
{
throw new IllegalArgumentException(“The Browser Type is Undefined”);
}
}

@Test
public void main() {

WebElement loginID = driver.findElement(By.id(“LoginID”));
loginID.click();
loginID.clear();
loginID.sendKeys(“rlewin600uk”);

WebElement password =driver.findElement(By.id(“Password”));
password.click();
password.clear();
password.sendKeys(“micegedim”);

WebElement SubmitButton = driver.findElement(By.id(“LoginButton”));
SubmitButton.click();

}
@AfterTest
public void closeBrowser()
{
driver.quit();
}
}

By this code i am able to run same test case on different machine and different browser.
I want to run same test case on different machine and on same Browser “ie”

nagesh1312 Default Answered on March 25, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.