0

我正在使用两个 Firefox 驱动程序运行测试以显示结果。我在我的电脑上使用两个屏幕。我可以通过在 Eclipse 中运行的 java 代码在每个屏幕上自动打开驱动程序吗?

谢谢。

4

1 回答 1

0

我认为您应该运行并行测试用例https://saucelabs.com/java/se2/8

@RunWith(Parallelized.class)
public class WebDriverParallelTest {

private String browser;
private String os;
private String version;

public WebDriverParallelTest(String os, String version, String browser) {
    super();
    this.os = os;
    this.version = version;
    this.browser = browser;
}

@Parameterized.Parameters
public static LinkedList browsersStrings() throws Exception {
    LinkedList browsers = new LinkedList();
    browsers.add(new String[]{Platform.XP.toString(), "17", "firefox"});
    //add any additional browsers here
    return browsers;
}

private WebDriver driver;

@Before
public void setUp() throws Exception {

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, browser);
    capabilities.setCapability(CapabilityType.VERSION, version);
    capabilities.setCapability(CapabilityType.PLATFORM, os);
    this.driver = new RemoteWebDriver(
            new URL("http://credential of sauce lab"), capabilities);
}

@Test
public void webDriver() throws Exception {
    driver.get("http://www.amazon.com/");
    assertEquals("Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more", driver.getTitle());
}

@After
public void tearDown() throws Exception {
    driver.quit();
}
}
于 2013-05-28T11:10:10.327 回答