Hello I have two node which names are Node1
and Node2
and I do this tests in one computer. My problem is Node1
and Node2
tests doesn't work same time so They are not parallel. Thus when Node1
is finish after Node2
test start but I don't want it , I want them start together.I have already tried parallel="tests"
and parallel="classes"
in the TestNG.xml
file.
This is my Node1.java
file:
package grid;
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.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
public class Node1 {
WebDriver driver;
String nodeUrl;
@Test
public void f() {
try {
//configuration
nodeUrl= "http://192.168.56.1:5555/wd/hub";
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setBrowserName("chrome");
capabilities.setPlatform(Platform.WIN10);
driver = new RemoteWebDriver(new URL(nodeUrl), capabilities);
//test scripts
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(45, TimeUnit.SECONDS);
driver.get("https://www.amazon.com/");
driver.findElement(By.linkText("Today's Deals")).click();
driver.findElement(By.linkText("Gift Cards")).click();
driver.findElement(By.linkText("Today's Deals")).click();
driver.findElement(By.linkText("Gift Cards")).click();
driver.findElement(By.linkText("Today's Deals")).click();
}
catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
This is my Node2.java
file :
package grid;
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.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
public class Node2 {
WebDriver driver;
String nodeUrl;
@Test
public void f() {
try {
//configuration
nodeUrl= "http://192.168.56.1:5555/wd/hub";
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setBrowserName("chrome");
capabilities.setPlatform(Platform.WIN10);
driver = new RemoteWebDriver(new URL(nodeUrl), capabilities);
//test scripts
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(45, TimeUnit.SECONDS);
driver.get("https://www.google.com/");
}
catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
And this is my TestNG.xml
file :
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Test Grid" parallel="tests">
<test name="Test Node1">
<classes>
<class name="grid.Node1" />
</classes>
</test>
<test name="Test Node2">
<classes>
<class name="grid.Node2" />
</classes>
</test>
</suite>
Aucun commentaire:
Enregistrer un commentaire