使用批处理文件运行Selenium TestNG脚本

时间:2016-09-16 11:50:21

标签: selenium batch-file webdriver testng

我正在尝试从命令提示符运行我的示例SELECT * FROM Member WHERE DATEPART(m, date_created) = DATEPART(m, DATEADD(m, -1, getdate())) AND DATEPART(yyyy, date_created) = DATEPART(yyyy, DATEADD(m, -1, getdate())) Selenium WebDriver脚本。我可以使用 Eclipse> Run As> TestNG Suite 运行它并获得预期的输出。但是,如果我从命令提示符运行相同的测试脚本,则测试将失败,并且没有任何错误消息,并显示以下输出:

TestNG

Eclipse中的控制台输出是:

C:\Gopal\jenkinsInt>java org.testng.TestNG testng.xml
[TestNG] Running:
  C:\Gopal\jenkinsInt\testng.xml

Jenkins integration

===============================================
Suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

我的示例脚本是:

[TestNG] Running:
  C:\Gopal\jenkinsInt\testng.xml

Jenkins integration
Google
===============================================
Suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================

1 个答案:

答案 0 :(得分:0)

TestNG正在运行且您的@Test方法(即testJenkins())失败。失败的根本原因可以在TestNG报告中看到。

从命令提示符运行testng.xml,正在打印Jenkins integration,而不是Google。所以很清楚你的测试方法逻辑开始执行,但由于Selenium的东西,它失败了。

<强>解决方案:
您需要确保TestNGSelenium也在classpath。{。} 有关更多信息和示例,您可以查看execute selenium test from command line

相关问题