【问题标题】:Running selenium tests using TestNG from the command line从命令行使用 TestNG 运行 selenium 测试
【发布时间】:2014-08-21 13:44:42
【问题描述】:

我目前正在使用 TestNG 从命令行运行我的 selenium 测试

java -cp \lib\testng.jar;
         \lib\selenium-server-standalone-2.42.2.jar;
         \lib\log4j-1.2.17.jar;
         \bin\. 
         org.testng.TestNG runTest.xml

但是,理想情况下,我希望将要使用的 webdriver 用作命令行参数。目前在我的 setUp() 中,它只是加载 firefox 驱动程序,更改驱动程序意味着注释和取消注释代码

所以作为我可以使用的最终目标。

-chrome -firefox

在 Firefox 和 chrome 上运行测试。

您建议哪种方法最好?

【问题讨论】:

    标签: java testing selenium selenium-webdriver testng


    【解决方案1】:

    您可以创建自定义参数 -Dbrowser=chrome 或 -Dbrowser=firefox。根据 Dbrowser 中的值,您需要在 setup() 方法中初始化适当的驱动程序。

    -Dbrowser 可以使用 System.getProperty("browser") 代码读取。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-25
      • 2014-04-23
      • 2016-04-25
      • 1970-01-01
      • 2018-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多