2

喜並行運行超過10次測試中,我設計了一個Selenium測試在並行(25)無法通過TestNG的數據提供程序

@Test(dataProvider = "getData") 
public void multiUserTest(String url, String username, String password) 
     throws InterruptedException, IOException, FindFailed { 

    DesiredCapabilities capabilities = DesiredCapabilities.chrome(); 
    capabilities.setBrowserName(prop.getProperty("browserName")); 
    capabilities.setPlatform(Platform.WINDOWS); 
    RemoteWebDriver driver = new RemoteWebDriver(new URL(prop.getProperty("url")), capabilities); 

    WebDriverWait wait = new WebDriverWait(driver, 720); // 12 minutes wait. 
    driver.manage().window().maximize(); 
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); 

    try { 
     driver.get(url); 
     driver.findElement(By.xpath(prop.getProperty("username"))).sendKeys(username); 
     driver.findElement(By.xpath(prop.getProperty("password"))).sendKeys(password); 
     driver.findElement(By.xpath(prop.getProperty("signin"))).click(); 
     }catch (Exception e) { 
     e.printStackTrace(); 
    } 

我的數據提供

@DataProvider(parallel = true) 
public Object[][] getData() { 

    Object data[][] = new Object[25][3]; 
    // row 1 
    data[0][0] = "http:XXXX/login.html"; 
    data[0][1] = "[email protected]"; 
    data[0][2] = "[email protected]"; 

    // row 2 
    data[1][0] = "http:XXXX/login.html"; 
    data[1][1] = "[email protected]"; 
    data[1][2] = "[email protected]"; 
    .......... 


    // row 25 
    data[24][0] = "http:XXXX/login.html"; 
    data[24][1] = "[email protected]"; 
    data[24][2] = "[email protected]"; 

和我的XML運行文件是

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> 
<suite name="Suite" parallel="methods" thread-count="1" data-provider-thread-count="25"> 
    <test name="Test"> 
    <classes> 
     <class name="XXX.MultiUserGuiTest"/> 
    </classes> 
    </test> <!-- Test --> 
</suite> <!-- Suite --> 

現在,當我運行我的上述測試它運行10次測試一次去和第10次測試後已完成,然後下一個1 0開始執行之後是5,但 我想運行我的測試,其中25應立即

僅供參考我加入我的EC2實例的截圖開始執行。有25鉻,起來和運行也請看看鼠標懸停在鉻瀏覽器

+0

你在哪裏在本地或網格上運行測試? – Paras

+0

在網格上。我們購買了亞馬遜EC2實例用於我們的測試 –

+0

您可以檢查在網格計算機上安裝了多少節點以及它們的最大實例嗎? – Paras

回答

1

嗨,我們已經找到了一種方式,我們能夠並行運行我們的25測試**但我不認爲這是做這個**的標準方式。請提供您的反饋或更好的方式來做以上的情況。

解決方案而不是使用數據表單數據提供商,我們已經刪除了數據提供完全 相反,我們呼籲參數利用

@Parameters({"param 1","param 2","param 3","and so on"}) in our test 

形成的testng.xml文件作爲參數,現在我可以看到我的25個節點的活躍同時成功執行所有操作。

相關問題