简体   繁体   English

使用@Test批注在远程计算机和本地计算机中并行运行一个测试用例

[英]Running one testcase in parallel in remote machine and local machine using @Test annotation

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 -->

When i am running the testing.xml file as TestNG both of the scripts are running on the remote machine(192.167.78.89) only...How i will run the script in local machine and remote machine parallel. 当我将Test.xml文件作为TestNG运行时,两个脚本都仅在远程计算机上运行(192.167.78.89)...我将如何在本地计算机和远程计算机上并行运行脚本。

Can someone help me out how to make it possible? 有人可以帮我解决这个问题吗?

Thanks, 谢谢,

Sudhansu 苏丹苏

One of your test should point local browser. 您的一项测试应指向本地浏览器。 If we change inFirefox() to do that, it will be like the following: 如果我们更改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();

}

Will this work? 这样行吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在本地计算机上运行并行测试 - Running parallel test in Local Machine 使用 Selenium Webdriver 连接远程数据库并通过 Eclipse 从本地机器运行测试用例 - Connect Remote Database using Selenium Webdriver and run Test Cases from local machine through eclipse 在虚拟机中运行测试 - Running test in virtual machine 使用Java将文件从本地计算机复制到远程计算机时需要帮助 - Need help in copying a file from local machine to remote machine using java 在本地计算机上使用硒网格运行并行测试时,webdriver返回与浏览器的通信错误 - webdriver returns error of communication with browser on parallel test run with selenium grid on local machine 在Jenkins节点上运行无头浏览器时出现ElementNotVisibleException。 测试用例使用chrome broswer在本地计算机上成功运行 - ElementNotVisibleException when running headless browser on Jenkins node. Test case runs successfully on local machine using chrome broswer 在特定时间在远程计算机上运行Jenkins。如何? - Running Jenkins on Remote Machine on a specific time ..how? 如何检查geckodriver在远程计算机上运行? - How to check a geckodriver is running on a remote machine? 我可以使用Java获取运行测试的Sauce Labs机器的远程IP地址吗? - Can I use java to get the remote ip address of the Sauce Labs machine running my test? 使用NUnit使用C#的Selenium WebDriver:在一台机器上并行在多个浏览器上执行测试用例 - Selenium WebDriver with C# using NUnit: execute test cases on multiple browsers in parallel on single machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM