我可以在2个屏幕上打开2个Firefox驱动程序吗?

时间:2013-05-28 08:51:32

标签: java eclipse firefox selenium

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

感谢。

1 个答案:

答案 0 :(得分: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();
}
}