我已经配置了一个节点和两个不同的节点。这两个节点机器都在Windows上运行,只在IE上运行。所以我想同时在这两个节点上运行我的测试脚本(并行)。但是,当我尝试这个脚本不是同时运行一个接一个。请在下面找到我的代码。
java -jar selenium-server-standalone-2.28.0.jar -role hub -port 8080

java -Dwebdriver.ie.driver=IEDriverServer.exe -jar selenium-server-standalone-2.28.0.jar -role node -hub http://172.29.70.143:8080/grid/register - browser "browserName=ie,maxInstances=10,platform=WINDOWS" -port 8080

public class Sample {
WebDriver driver;
String baseUrl, nodeUrl;
@BeforeTest
public void setUp() throws MalformedURLException {
baseUrl = "https://10.87.137.219/selfRegistration_sit/";
nodeUrl = "http://172.29.70.143:8080/wd/hub";
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
capability
.setCapability(
InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
true);
capability.setBrowserName("ie");
capability.setPlatform(Platform.WINDOWS);
driver = new RemoteWebDriver(new URL(nodeUrl), capability);
capability
.setCapability(
InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
true);
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@Test
public void test() throws Exception {
driver.navigate().to(baseUrl);
driver.navigate().to(
"javascript:document.getElementById('overridelink').click()");
// System.out.println("Certifi");
// System.out.println("After certifi");
// click on register Non VIL
driver.findElement(By.id("ctl00_ContentPlaceHolder1_img_reg")).click();
// enter supervisor name
driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtEmployeeID"))
.sendKeys("90001451");
// click on search
driver.findElement(By.name("ctl00$ContentPlaceHolder1$IbtnGetDetTab3"))
.click();
Thread.sleep(2000);
// //click on select
List<WebElement> List=driver.findElements(
By.xpath("//a[contains(@href,'javascript:__doPostBack(')]"));
List.get(1).click();
driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtName"))
.sendKeys("Mani");
// select circle
new Select(driver.findElement(By
.name("ctl00$ContentPlaceHolder1$drpCircle")))
.selectByVisibleText("GUJARAT");
// location
driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtLocation"))
.sendKeys("Location");
// departmenr
driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtDept"))
.sendKeys("Department");
// mobilenumber
driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtMobile"))
.sendKeys("8983152157");
// sub departmnet
driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtSubdept"))
.sendKeys("Sub Department");
// email
driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtOwnerEamil"))
.sendKeys("Email");
// domain
new Select(driver.findElement(By
.name("ctl00$ContentPlaceHolder1$drpmailids")))
.selectByVisibleText("VODA.COM");
// designation
driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtDesignation"))
.sendKeys("Designation");
// org name
driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtVendorname"))
.sendKeys("Organistaion");
// POI type
new Select(driver.findElement(By
.name("ctl00$ContentPlaceHolder1$ddlPOI_TYPE")))
.selectByVisibleText("PAN Card");
// POI value
driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtPOI_Value"))
.sendKeys("PAN123413");
// //physical
driver.findElement(By.id("ctl00_ContentPlaceHolder1_rbAccess_0"))
.click();
// vf user
driver.findElement(By.id("ctl00_ContentPlaceHolder1_rbEmpVf_1"))
.click();
// click on proceed
driver.findElement(By.name("ctl00$ContentPlaceHolder1$IbtnSubmit"))
.click();
}
&#13;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests" thread-count="2">
<test name="IETest">
<parameter name="browser" value="ie" />
<classes>
<class name="testScripts.Sample" />
</classes>
</test>
</suite>
&#13;
答案 0 :(得分:-1)
你有并行=&#34;测试&#34;在你的testng xml配置文件中,它只有一个测试标记。有多个测试标签指向代码中的单个测试方法以运行并行测试或更改并行=&#34;测试&#34;并行=&#34;方法&#34;并在类中保留至少两个方法,以便它并行运行两个测试方法。