RE: 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 Answers

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”

Default Answered on March 25, 2015.
Add Comment

Your Answer

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