2015-09-04 70 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

相关问题