2013-10-29 31 views
1

我正在使用硒網格(JUNIT,Java)在瀏覽器的多實例上運行我的測試用例。 我用「java -jar selenium-server-standalone-2.20.0.jar -role hub」來運行集線器。 和「java -jar selenium-server-standalone-2.20.0.jar -role webdriver -hub http:// machineip:4444/grid/register -port 5566」來運行節點。無法使用硒網格打開多個實例的瀏覽器

我證實,兩者都運行良好。

但是,當我通過eclipse運行testcase時,只打開了一個瀏覽器實例。

我用這段代碼。

@Test 
public void method() throws MalformedURLException { 
    baseUrl = "https://www.google.co.in"; 
    nodeUrl = "http://`machinip`:5566/wd/hub"; 
    DesiredCapabilities capability = DesiredCapabilities.firefox(); 
    capability.setBrowserName("firefox"); 
    capability.setPlatform(Platform.WINDOWS); 
    driver = new RemoteWebDriver(new URL(nodeUrl), capability); 
    // WebDriver driver = new FirefoxDriver(); 
    driver.get(baseUrl); 
    driver.findElement(By.xpath("//td/div/input")).sendKeys("lucky"); 
} 

可以請某人建議如何打開多個實例進行單一測試。

在此先感謝您的幫助。

+0

它看起來像你只創建1名司機那裏。我沒有看到兩名司機進來。 –

+0

你的意思是如果我必須運行10個實例,我已經創建了10個驅動程序? 您能否提供該代碼? –

+0

爲什麼不嘗試TestNG呢?它更容易做這樣的作品;) –

回答

0

嘗試啓動服務器 -browser MAXINSTANCES = 5

1

您測試代碼在總體上是好的,當加入這種標籤 - 單個測試) 我認爲你缺少你運行測試的方式 - 如果你單次運行它將打開一個實例。在testNg中,您可以使用dataprovider(參數化)多次運行它,並在testing.xml中指定您需要「parallel = methods」,這樣,測試的所有「參數化」實例將一起運行。 還確保在節點起始行(或任何您想要的數字)中有-browser maxInstances = 5。

efficient selenium testing lab

[披露:我在工作拉維羅]

相關問題