Download Set Selenium Grid Node "timeout" When Running WebDriver Test - Software Testing Tutorials graphic type that can be scaled to use with the Silhouette Cameo or Cricut. An SVG's size can be increased or decreased without a loss of quality. All of our downloads include an image, Silhouette file, and SVG file. It should be everything you need for your next project. Our SVG files can be used on adhesive vinyl, heat transfer and t-shirt vinyl, or any other cutting surface
fillingForm.java
package Grid2;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class fillingForm {
@Test(dataProvider = "getNames")
public void gmailLogin(String browser, String fName, String lName) throws MalformedURLException, InterruptedException {
System.out.println(browser);
DesiredCapabilities cap = null;
if (browser.equals("firefox")) {
cap = DesiredCapabilities.firefox();
cap.setBrowserName("firefox");
cap.setPlatform(Platform.WINDOWS);
} else if (browser.equals("chrome")) {
cap = DesiredCapabilities.chrome();
cap.setBrowserName("chrome");
cap.setPlatform(Platform.WINDOWS);
}
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), cap);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://only-testing-blog.blogspot.in/2014/05/form.html");
driver.findElement(By.name("FirstName")).sendKeys(fName);
driver.findElement(By.name("LastName")).sendKeys(lName);
// Commented driver.quit(); to verify browser is being closed automatically by timeout or not.
// driver.quit();
}
@DataProvider(parallel = true)
public Object[][] getNames() {
Object data[][] = new Object[2][3];
data[0][0] = "firefox";
data[0][1] = "FirstName1";
data[0][2] = "LastName1";
data[1][0] = "chrome";
data[1][1] = "FirstName2";
data[1][2] = "LastName2";
return data;
}
}
Calc.java
package Grid2;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class Calc {
@Test(dataProvider = "getCalcData")
public static void calcTest(String browser, String num1, String num2, String expSumNum) throws MalformedURLException, InterruptedException {
System.out.println(browser);
DesiredCapabilities cap = null;
if (browser.equals("firefox")) {
cap = DesiredCapabilities.firefox();
cap.setBrowserName("firefox");
cap.setPlatform(Platform.WINDOWS);
} else if (browser.equals("chrome")) {
cap = DesiredCapabilities.chrome();
cap.setBrowserName("chrome");
cap.setPlatform(Platform.WINDOWS);
}
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), cap);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://only-testing-blog.blogspot.in/2014/04/calc.html");
driver.findElement(By.xpath("//input[@id='Resultbox']")).clear();
driver.findElement(By.xpath("//input[@id='" + num1 + "']")).click();
driver.findElement(By.xpath("//input[@id='plus']")).click();
driver.findElement(By.xpath("//input[@id='" + num2 + "']")).click();
driver.findElement(By.xpath("//input[@id='equals']")).click();
String strResult = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value");
int actualResult = Integer.parseInt(strResult);
int expectedResult = Integer.parseInt(expSumNum);
Assert.assertEquals(actualResult, expectedResult);
// Commented driver.quit(); to verify browser is being closed automatically by timeout or not.
// driver.quit();
}
@DataProvider(parallel = true)
public Object[][] getCalcData() {
Object data[][] = new Object[2][4];
data[0][0] = "firefox";
data[0][1] = "1";
data[0][2] = "3";
data[0][3] = "4";
data[1][0] = "chrome";
data[1][1] = "2";
data[1][2] = "5";
data[1][3] = "7";
return data;
}
}
testng.xml
<suite name="My Test Suite" verbose="2" parallel="classes" thread-count="6">
<test name="Selenium Grid Test">
<classes>
<class name="Grid2.fillingForm" />
<class name="Grid2.Calc" />
</classes>
</test>
</suite>
- 2 Software Automation Test cases : fillingForm.java and Calc.java
- driver.quit(); is commented from both software automation test cases so webdriver will not close driver instance.
- Both tests are configured to run in parallel using selenium grid 2.
- Our aim is to run both software automation test cases in parallel in 2 browsers and also it should run max 2 browsers at a time so we will launch node with -maxSession 2.
- Start grid hub as described in THIS POST.
- Open command prompt and navigate to D: drive in command prompt where selenium server jar file, IEDriver server file and chromedriver file is stored.
- Start grid node with -maxSession 2 to restrict 2 max browsers only at a time. timeout is not used. Launch node using bellow given command.
java -jar selenium-server-standalone-2.52.0.jar -role node -Dwebdriver.ie.driver="D:/IEDriverServer.exe" -Dwebdriver.chrome.driver="D:/chromedriver.exe" -hub http://localhost:4444/grid/register -port 5566 -browser browserName=firefox,maxInstances=2 -browser browserName=chrome,maxInstances=2 -browser browserName=iexplore,maxInstances=2 -maxSession 2
- Restart grid hub.
- Restart grid node using bellow command. Here we have used -timeout 20000 (20 seconds) at the end of command. You can set timeout as per your requirement.
java -jar selenium-server-standalone-2.52.0.jar -role node -Dwebdriver.ie.driver="D:/IEDriverServer.exe" -Dwebdriver.chrome.driver="D:/chromedriver.exe" -hub http://localhost:4444/grid/register -port 5566 -browser browserName=firefox,maxInstances=2 -browser browserName=chrome,maxInstances=2 -browser browserName=iexplore,maxInstances=2 -maxSession 2 -timeout 20000
Download Set Selenium Grid Node "timeout" When Running WebDriver Test - Software Testing Tutorials All SVG file downloads also come bundled with DXF, PNG, and EPS file formats. All designs come with a small business commercial license. These SVG cut files are great for use with Silhouette Cameo or Cricut and other Machine Tools.