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

當我將Test.xml文件作為TestNG運行時,兩個腳本都僅在遠程計算機上運行(192.167.78.89)...我將如何在本地計算機和遠程計算機上並行運行腳本。

有人可以幫我解決這個問題嗎?

謝謝,

蘇丹蘇

您的一項測試應指向本地瀏覽器。 如果我們更改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();

}

這樣行嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM