WebDriver - 测试多个平台

WebDriver - Testing Multiple Platforms

我想使用 Selenium Webdriver 来测试使用 JUnit 的网络应用程序。我想用相同的测试用例来测试不同的浏览器;示例:首先,我想 运行 我在 chrome 上的所有场景,然后我想自动 运行 我在 Firefox 上的所有场景。

建议的方法是什么?

    if(arg1 == "chrome"){ 
      _driver = new ChromeDriver();
    }
    if(arg1 == "firefox")
      _driver = new firefoxDriver();
    }

我决定使用参数化的 JUnit 测试,作为参数我在参数列表中初始化了适当的 PageObject,请参见下面的示例:

@Parameters
        public static Collection<Object[]> data() {
            return Arrays.asList(new Object[][] {
                    { new ChromePageObject() },
                    { new FirefoxPageObject() }
            });
        }