2015-09-04 23 views

回答

0

是的,你可以使用網格。我將給你一個簡單的例子。創建兩個類TestNG中和,並設置類的testng.xml

現在用在如下兩個類代碼: -

公共類的測試{

 public static try1 { 
     try{ 

      String baseUrl="https://www.google.com/";  // url on which we have to test 
      String nodeurl="http://192.168.10.30:5555/wd/hub"; // ip and port of node remote machine 2 we are using as node for testing. 
     System.setProperty("webdriver.chrome.driver","C:/robot/chromedriver.exe"); 


      // the below line have chrome capability then explorer works dont change it to explorer it doesn't work 
     WebDriver driver = new RemoteWebDriver(new URL(nodeurl), DesiredCapabilities.chrome()); 
     driver.get(baseUrl); 


     WebElement element = driver.findElement(By.name("q")); 
     element.sendKeys("BrowserStack"); 
     element.submit(); 

     System.out.println(driver.getTitle()); 
     driver.quit(); 
     } 

現在這兩類配置不同的網站,在那裏設置ips並按照您在其他salve機器中設置的那樣提供端口。

如果你想運行它們相互平行,然後簡單地把parallel="tests"在你的testng.xml

<suite name="Test-class Suite" parallel="tests" thread-count="2"> 

我希望它會幫助你:)

+0

謝謝我馬上試試:D – Gornie

+0

發生了什麼事。這不適合你嗎?你可以告訴我,所以我可以更正自己,如果有任何 –

+0

哎呀對不起,這是錯誤的點擊 我只是想複製「公共類測試{...」 \ – Gornie

相關問題