我能够通过命令提示符运行 selenium webdriver 支持的脚本触发 ant。
测试脚本运行成功,生成的 Junit 测试结果在报告中带有屏幕截图。
在 Jenkins 上运行相同的脚本,chrome 浏览器未启动,构建成功,但是 Junit 测试报告不完整,屏幕截图没有出现。看起来脚本中的操作也没有执行。
请参阅下面来自 Jenkins 控制台输出的日志以了解该作业。
我的测试 PC 的操作系统是 windows XP 和 chrome ver30。通过 Jenkins 运行时,相同的脚本在 IE 和 Firefox 浏览器上运行良好(能够看到浏览器启动并执行 action.pls 协助。
日志信息:
[testng] log4j: reset attribute= "false".
[testng] log4j: Threshold ="null".
[testng] log4j: Level value for root is [debug].
[testng] log4j: root level set to DEBUG
[testng] log4j: Class name: [org.apache.log4j.ConsoleAppender]
[testng] log4j: Setting property [threshold] to [INFO].
[testng] log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
[testng] log4j: Setting property [conversionPattern] to [%d{ABSOLUTE} %-5p %c{1} : %m%n].
[testng] log4j: Adding appender named [std-out] to category [root].
[testng] log4j: Class name: [org.apache.log4j.RollingFileAppender]
[testng] log4j: Setting property [file] to [debug.log].
[testng] log4j: Setting property [maxFileSize] to [50MB].
[testng] log4j: Setting property [maxBackupIndex] to [10].
[testng] log4j: Setting property [threshold] to [DEBUG].
[testng] log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
[testng] log4j: Setting property [conversionPattern] to [%d{ABSOLUTE} %-5p %c{1} : %m%n].
[testng] log4j: setFile called: debug.log, true
[testng] log4j: setFile ended
[testng] log4j: Adding appender named [debug-out] to category [root].
[testng] 19:04:22,875 INFO BaseSeleniumTest : total test methods found:1
[testng] 19:04:22,875 INFO BaseSeleniumTest :
[testng] CHECKING IF ANY WEBDRIVERS HAVE NOT PREVIOUSLY BEEN ADDED:
[testng] 19:04:22,875 INFO BaseSeleniumTest : BROWSER NOT PRESENT SO ADDING BROWSER:CH
[testng] 19:04:22,875 INFO WebDriverSupplier : Requested to ADD a webbrowser supplier for :CH
[testng] 19:04:22,875 INFO WebDriverSupplier : ADDED webbrowser supplier for :CH the complete map now contains the following:[CH]
[testng] [TestNG] Running:
[testng] Selenium Regression Tests
[testng]
[testng] 19:04:23,328 INFO BaseSeleniumTest : SET UP REPORTER FOR test1
[testng] 19:04:23,359 INFO BaseSeleniumTest : RETURN:1
[testng] Starting ChromeDriver (v2.3) on port 54671
[testng] org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
[testng] (Driver info: chromedriver=2.3,platform=Windows NT 5.1 SP3 x86) (WARNING: The server did not provide any stacktrace information)
[testng] Command duration or timeout: 875 milliseconds
[testng] Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01'
[testng] System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0_10'
[testng] Driver info: org.openqa.selenium.chrome.ChromeDriver
[testng] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[testng] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
[testng] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[testng] at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
[testng] at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:191)
[testng] at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
[testng] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
[testng] at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
[testng] at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
[testng] at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
[testng] at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:161)
[testng] at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
[testng] at com.examples.core.WebDriverSupplier$1.get(WebDriverSupplier.java:54)
[testng] at com.examples.core.WebDriverSupplier$1.get(WebDriverSupplier.java:39)
[testng] at com.examples.tests.test1.testMethod(test1.java:24)
[testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[testng] at java.lang.reflect.Method.invoke(Method.java:601)
[testng] at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
[testng] at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
[testng] at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
[testng] at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
[testng] at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
[testng] at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
[testng] at org.testng.TestRunner.privateRun(TestRunner.java:767)
[testng] at org.testng.TestRunner.run(TestRunner.java:617)
[testng] at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
[testng] at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
[testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
[testng] at org.testng.SuiteRunner.run(SuiteRunner.java:240)
[testng] at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
[testng] at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
[testng] at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
[testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
[testng] at org.testng.TestNG.run(TestNG.java:1057)
[testng] at org.testng.TestNG.privateMain(TestNG.java:1364)
[testng] at org.testng.TestNG.main(TestNG.java:1333)
[testng] 19:04:26,421 INFO BaseSeleniumTest : finished running 1/1 DECLARED TESTS against 1/1 BROWSERS defined
[testng] 19:04:26,421 INFO BaseSeleniumTest : finished TEST SUITE 1 out of 1 to run
testng] Starting ChromeDriver (v2.3) on port 52079
[testng]
[testng] ===============================================
[testng] Selenium Regression Tests
[testng] Total tests run: 1, Failures: 0, Skips: 0
[testng] Configuration Failures: 1, Skips: 0
[testng] ===============================================
[testng]
[testng] The tests failed.
run-junit-report:
[exec] Buildfile: C:\Program Files\Jenkins\workspace\myeg maintenance\Selenium-Regression-Project-master\RegressionTestHarness\build.xml
[exec]
[exec] report:
[exec] [junitreport] Processing C:\Program Files\Jenkins\workspace\myeg maintenance\Selenium-Regression-Project-master\RegressionTestHarness\results\junitreports\TESTS-TestSuites.xml to C:\WINDOWS\TEMP\null943067594
[exec] [junitreport] Loading stylesheet C:\Program Files\Jenkins\workspace\myeg maintenance\Selenium-Regression-Project-master\RegressionTestHarness\xsl\junit-frames.xsl
[exec] [junitreport] Transform time: 1219ms
[exec] [junitreport] Deleting: C:\WINDOWS\TEMP\null943067594
[exec]
[exec] check.archive.results:
[exec]
[exec] archive.results:
[exec] [echo] Archiving results....
[exec] [copy] Copying 40 files to C:\Program Files\Jenkins\workspace\myeg maintenance\Selenium-Regression-Project-master\RegressionTestHarness\archives\results_09-10-2013-0704
[exec]
[exec] copy.images:
[exec] [copy] Copying 4 files to C:\Program Files\Jenkins\workspace\myeg maintenance\Selenium-Regression-Project-master\RegressionTestHarness\results\junitreports\com\examples\images
[exec] [copy] Copying 8 files to C:\Program Files\Jenkins\workspace\myeg maintenance\Selenium-Regression-Project-master\RegressionTestHarness\results\junitreports\com\examples\images\media
[exec] [delete] Deleting directory C:\Program Files\Jenkins\workspace\myeg maintenance\Selenium-Regression-Project-master\RegressionTestHarness\results\junitreports\com\examples\images\templates
[exec] [delete] Deleting directory C:\Program Files\Jenkins\workspace\myeg maintenance\Selenium-Regression-Project-master\RegressionTestHarness\SeleniumTestResults
[exec]
[exec] BUILD SUCCESSFUL
[exec] Total time: 2 seconds
BUILD SUCCESSFUL
Total time: 19 seconds
Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at BUILD level C:\Program Files\Jenkins\workspace\myeg maintenance to C:\Program Files\Jenkins\jobs\myeg maintenance\builds\2013-10-09_19-04-10\htmlreports\HTML_Report
Finished: SUCCESS