2014-03-27 80 views
0
Hi Everyone, 

I want to run one testcase in two different machines parallel with different combinations of OS and Browser. But when iam running it is running in remote machine only but parallel..How to run in two machines in parallel? 

I am using the below code to make it happen. 

Running in Chrome browser in Remote machine in 5556 port 
    @Test 
    public void inChrome() throws MalformedURLException { 

    DesiredCapabilities capability = DesiredCapabilities.chrome(); 
    // Setting the browser 
    capability.setBrowserName(BrowserType.CHROME); 
    // Setting the platform 
    capability.setPlatform(Platform.WINDOWS); 
    // Running in the remote machine. 
    WebDriver driver = new RemoteWebDriver(new URL(
     "http://192.167.78.89:5556/wd/hub"), capability); 
    driver.get("https://www.google.co.in/"); 
    driver.close(); 

    } 

// Running in firefox browser in local machine where hub is running 
    @Test 
    public void inFirefox() throws MalformedURLException { 
    DesiredCapabilities capability = DesiredCapabilities.firefox(); 
    // Setting the browser 
    capability.setBrowserName(BrowserType.FIREFOX); 
    // Setting the platform 
    capability.setPlatform(Platform.WINDOWS); 
    // Running in the local machine. 
    WebDriver driver = new RemoteWebDriver(new URL(
     "http:// :4444/wd/hub"), capability); 
    driver.get("https://www.google.co.in/"); 
    driver.close(); 

    } 

and i have testing.xml file 

<?xml version="1.0" encoding="UTF-8"?> 
<suite name="classname" verbose="3"> 
    <test name="Test" parallel="methods" thread-count="3"> 
    <classes> 
     <class name="packagename.classname"/> 
    </classes> 
    </test> <!-- Test --> 
</suite> <!-- Suite --> 

当我以TestNG身份运行tests.xml文件时,两个脚本仅在远程计算机(192.167.78.89)上运行。 。我将如何在本地机器和远程机器并行运行脚本。使用@Test注释在远程计算机和本地计算机上并行运行一个测试用例

有人可以帮我解决问题吗?

感谢,

Sudhansu

回答

0

你的一个测试应该指向本地浏览器。如果我们更改inFirefox()来做到这一点,它将如下所示:

@Test 
public void inFirefox() throws MalformedURLException { 
// Running in the local machine. 
WebDriver driver = new FirefoxDriver(); 
driver.get("https://www.google.co.in/"); 
driver.close(); 

} 

这个工作吗?

+0

感谢Sitam,它不工作......写完上面的代码后,它在本地机器上打开Chrome之后,它在远程机器上的ff浏览器中打开......这不是我的要求..我需要运行脚本在远程和本地并行执行 – user3411418

相关问题