2013-05-28 56 views

回答

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(); 
} 
} 
相關問題