定义将在各种浏览器上运行单个浏览器测试的测试工厂

时间:2014-10-03 17:48:29

标签: selenium selenium-webdriver testng saucelabs

我正在尝试概述如何实现Factory以在我定义的所有浏览器上测试测试类。有一个更好的方法吗。任何人都可以建议一个基本的改进吗?

public class FactoryDataProviderTestBase extends MyTestBase 
{
  @Factory(dataProvider = "dp")
  public FactoryDataProviderTestBase( SauceTestHelper helper, 
       Map<String,String> csvArgMap ) {
    super( helper,  csvArgMap );
  }

  @DataProvider( name = "factory" )
  static public Object[][] factoryDataProvider() {

    // do stuff here to initialize csvArgMap from csv file

    return new Object[][] {
      new Object[] { new SauceTestHelper(browser.FirefoxLatest), argMap },
      new Object[] { new SauceTestHelper(browser.IE8), argMap },
      new Object[] { new SauceTestHelper(browser.IE9), argMap },
      new Object[] { new SauceTestHelper(browser.IE10), argMap },
      new Object[] { new SauceTestHelper(browser.IE11), argMap },
      new Object[] { new SauceTestHelper(browser.Safari7), argMap },
      new Object[] { new SauceTestHelper(browser.Chrome), argMap }
    };

  }
}

在上面的代码中,TestNG应该创建类FactoryDataProviderTestBase的多个实例,每个实例定义一个浏览器?

1 个答案:

答案 0 :(得分:-1)

您应该使用Selenium's Grid。可以找到设置和配置信息here