我的团队正在考虑使用 Selenium 2 进行 UI 测试。我们的 UI 开发由外部供应商完成(另一个主题),使用 RemoteDriver(服务器/客户端)需要更多的维护而不是我们的生产力。
我的测试项目是一个简单的 maven 项目,我尝试启动一个新的 IE(v8 - 64bit)/Firefox/和 Chrome 浏览器,看看它是否会成功导航到某个任意 url。它在我的机器上本地运行,在 TeamCity build-agent 用户配置文件上远程运行(转到源项目并运行 mvn test)。但是,当我尝试通过 TeamCity 控制台(Web 或通过 IntelliJ 上的远程运行)执行测试时,出现以下错误:
IE 驱动程序错误
[17:19:57][it:test] Started InternetExplorerDriver server (32-bit)
[17:19:57][it:test] 2.25.3.0
[17:19:57][it:test] Listening on port 34154
[17:20:00][it:test] Oct 23, 2012 5:20:00 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
[17:20:00][it:test] INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond
[17:20:00][it:test] Oct 23, 2012 5:20:00 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
[17:20:00][it:test] INFO: Retrying request
[17:20:01][it:test] [1A [32mWhen [0m [32mI launch " [0m [32m [1mie [0m [32m" on TeamCity [0m [90m# Browser_Steps.I_launch_browser_on_TeamCity(String) [0m
[17:20:01][it:test] [90mThen [0m [90mI should see that the browser was launched [0m [90m# Browser_Steps.I_should_see_that_the_browser_was_launched() [0m
[17:20:02][it:test] [1A [31mThen [0m [31mI should see that the browser was launched [0m [90m# Browser_Steps.I_should_see_that_the_browser_was_launched() [0m
[17:20:02][it:test] [31morg.openqa.selenium.UnhandledAlertException: Modal dialog present
[17:20:02][it:test] Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
[17:20:02][it:test] System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_33'
[17:20:02][it:test] Driver info: driver.version: RemoteWebDriver
[17:20:02][it:test] Session ID: 2244723f-8097-4a0d-9e9b-45d13f68c5ae
[17:20:02][it:test] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[17:20:02][it:test] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
[17:20:02][it:test] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
[17:20:02][it:test] at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
[17:20:02][it:test] at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
[17:20:02][it:test] at org.openqa.selenium.remote.ErrorHandler.createUnhandledAlertException(ErrorHandler.java:169)
[17:20:02][it:test] at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:141)
[17:20:02][it:test] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:458)
[17:20:02][it:test] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:462)
[17:20:02][it:test] at org.openqa.selenium.remote.RemoteWebDriver.getTitle(RemoteWebDriver.java:204)
[17:20:02][it:test] at Browser_Steps.I_should_see_that_the_browser_was_launched(Browser_Steps.java:102)
[17:20:02][it:test] at ?.Then I should see that the browser was launched(Browsers.feature:7)
Chrome 驱动程序错误
[17:20:19][it:test] Started ChromeDriver
[17:20:19][it:test] port=1099
[17:20:19][it:test] version=23.0.1240.0
[17:20:19][it:test] log=C:\BuildAgent1\work\6df7fefd08b17c16\chromedriver.log
[17:29:26][it:test] The build myDB::selenium_ci #23 {builId=34261} has been running for more than 10 minutes. Terminating...
[17:29:26][it:test] [Execution timeout] {build.status.text}
[17:29:29][it:test] Dumping threads before termination:
[17:29:29][it:test] PID: 7088, PPID: 6128, Command line: \\usrduws708221\SHARED_TOOLS\java\jdk1.6.0_33\bin\java.exe -Dagent.home.dir=C:\BuildAgent1 -Dagent.name=USRDUWS345623-MyDB1 -Dagent.ownPort=9091 -Dagent.work.dir=C:\BuildAgent1\work -Dbuild.number=23 -Dbuild.vcs.number=76 -Dbuild.vcs.number.1=76 -Dbuild.vcs.number.selenium_ci=76 -Dclassworlds.conf=C:\BuildAgent1\temp\buildTmp\teamcity.m2.conf -Dcom.jetbrains.maven.watcher.report.file=C:\BuildAgent1\temp\buildTmp\maven-build-info.xml -Dfile.encoding=Cp1252 -Dfile.separator=\ -Djava.io.tmpdir=C:\BuildAgent1\temp\buildTmp -Dmaven.home=\\usrduws708221\SHARED_TOOLS\maven\apache-maven-3.0.4 -Dos.arch=x86 "-Dos.name=Windows 7" -Dos.version=6.1 -Dpath.separator=; -Dteamcity.agent.cpuBenchmark=325 -Dteamcity.agent.dotnet.agent_url=http://localhost:9091/RPC2 -Dteamcity.agent.dotnet.build_id=34261 -Dteamcity.auth.password=sYOEwtcTr6zExWPuECfytw8Nbfb4c1cd -Dteamcity.auth.userId=TeamCityBuildId=34261 -Dteamcity.build.changedFiles.file=C:\BuildAgent1\temp\buildTmp\changedFiles7023604667624871531.txt -Dteamcity.build.checkoutDir=C:\BuildAgent1\work\6df7fefd08b17c16 -Dteamcity.build.id=34261 -Dteamcity.build.properties.file=C:\BuildAgent1\temp\buildTmp\teamcity.build686343423326544568.properties -Dteamcity.build.tempDir=C:\BuildAgent1\temp\buildTmp -Dteamcity.build.workingDir=C:\BuildAgent1\work\6df7fefd08b17c16 -Dteamcity.buildConfName=selenium_ci -Dteamcity.buildType.id=bt300 -Dteamcity.configuration.properties.file=C:\BuildAgent1\temp\buildTmp\teamcity.config4225430352183826801.properties -Dteamcity.dotnet.nunitaddin=C:\BuildAgent1\plugins\dotnetPlugin\bin\JetBrains.TeamCity.NUnitAddin-NUnit -Dteamcity.dotnet.nunitlauncher=C:\BuildAgent1\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe -Dteamcity.dotnet.nunitlauncher.msbuild.task=C:\BuildAgent1\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MSBuildLoggers.dll -Dteamcity.dotnet.nunitlauncher1.1=C:\BuildAgent1\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher1.1.exe -Dteamcity.dotnet.nunitlauncher2.0=C:\BuildAgent1\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher2.0.exe -Dteamcity.dotnet.nunitlauncher2.0.vsts=C:\BuildAgent1\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher2.0.VSTS.exe -Dteamcity.dotnet.platform=C:\BuildAgent1\plugins\dotnetPlugin\bin\JetBrains.TeamCity.PlatformProcessRunner.1.1.exe -Dteamcity.maven.watcher.home=C:\BuildAgent1\plugins\mavenPlugin\maven-watcher -Dteamcity.projectName=myDB -Dteamcity.runner.properties.file=C:\BuildAgent1\temp\buildTmp\teamcity.runner1044140889240461617.properties -Dteamcity.tests.recentlyFailedTests.file=C:\BuildAgent1\temp\buildTmp\testsToRunFirst8927992996360649639.txt "-Dteamcity.version=7.0.1 (build 21326)" -Duser.country=US -Duser.home=C:\ -Duser.language=en -Duser.name=SYSTEM -Duser.timezone=America/New_York -Duser.variant= -classpath \\usrduws708221\SHARED_TOOLS\maven\apache-maven-3.0.4\boot\plexus-classworlds-2.4.jar; org.codehaus.plexus.classworlds.launcher.Launcher -f C:\BuildAgent1\work\6df7fefd08b17c16\pom.xml -B -Dmaven.repo.local=//Usrduws708221/shared_tools/maven/repository test -s C:\BuildAgent1\temp\buildTmp\maven_settings_1267417561803171768.xml
[17:29:29][it:test] 2012-10-23 17:29:29 Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.8-b03 mixed mode): "Thread-2" prio=6 tid=0x0000000006fc4800 nid=0x18ac runnable [0x000000000b7af000] java.lang.Thread.State: RUNNABLE at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:220) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158) - locked <0x00000007aba50a78> (a java.io.InputStreamReader) at java.io.InputStreamReader.read(InputStreamReader.java:167) at java.io.BufferedReader.fill(BufferedReader.java:136) at java.io.BufferedReader.readLine(BufferedReader.java:299) - locked <0x00000007aba50a78> (a java.io.InputStreamReader) at java.io.BufferedReader.readLine(BufferedReader.java:362) at org.codehaus.plexus.util.cli.StreamPumper.run(StreamPumper.java:129) "Thread-1" prio=6 tid=0x0000000006fc4000 nid=0x3f0 runnable [0x000000000b5df000] java.lang.Thread.State: RUNNABLE at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:220) at java.io.BufferedInputStream.read1(BufferedInputStream.java:256) at java.io.BufferedInputStream.read(BufferedInputStream.java:317) - locked <0x00000007aba44fb0> (a java.io.BufferedInputStream) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158) - locked <0x00000007aba4dd20> (a java.io.InputStreamReader) at java.io.InputStreamReader.read(InputStreamReader.java:167) at java.io.BufferedReader.fill(BufferedReader.java:136) at java.io.BufferedReader.readLine(BufferedReader.java:299) - locked <0x00000007aba4dd20> (a java.io.InputStreamReader) at java.io.BufferedReader.readLine(BufferedReader.java:362) at org.codehaus.plexus.util.cli.StreamPumper.run(StreamPumper.java:129) "ThreadedStreamConsumer" prio=6 tid=0x0000000006fc3000 nid=0x1ecc waiting on condition [0x000000000b47f000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000007aba1cba0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:399) at org.apache.maven.surefire.util.internal.Java15BlockingQueue.take(Java15BlockingQueue.java:40) at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:68) at java.lang.Thread.run(Thread.java:662) "resolver-4" daemon prio=6 tid=0x0000000006fc2800 nid=0x1b68 waiting on condition [0x000000000b27f000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000007af7b9ae8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:399) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:662) "resolver-3" daemon prio=6 tid=0x0000000006fc1800 nid=0x1f7c waiting on condition [0x000000000b17f000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000007af7b9ae8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:399) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:662) "resolver-2" daemon prio=6 tid=0x0000000009dbf000 nid=0x1cec waiting on condition [0x000000000900f000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000007af7b9ae8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:399) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:662) "resolver-1" daemon prio=6 tid=0x000000000a04c800 nid=0x1878 waiting on condition [0x0000000008e7f000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000007af7b9ae8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:399) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:662) "Low Memory Detector" daemon prio=6 tid=0x0000000006eb3800 nid=0x19d4 runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE "C2 CompilerThread1" daemon prio=10 tid=0x0000000006ea2800 nid=0x1a58 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "C2 CompilerThread0" daemon prio=10 tid=0x0000000006e9b000 nid=0x1e1c waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "Attach Listener" daemon prio=10 tid=0x0000000006e9a000 nid=0x14ec waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "Signal Dispatcher" daemon prio=10 tid=0x0000000006e99800 nid=0x1f74 runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE "Finalizer" daemon prio=8 tid=0x0000000006e3e000 nid=0x14e4 in Object.wait() [0x0000000007b7f000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000007af6a0330> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118) - locked <0x00000007af6a0330> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159) "Reference Handler" daemon prio=10 tid=0x0000000006e3a800 nid=0x1120 in Object.wait() [0x0000000007a7f000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000007af6a0568> (a java.lang.ref.Reference$Lock) at java.lang.Object.wait(Object.java:485) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116) - locked <0x00000007af6a0568> (a java.lang.ref.Reference$Lock) "main" prio=6 tid=0x0000000000498000 nid=0x34c runnable [0x00000000026de000] java.lang.Thread.State: RUNNABLE at java.lang.ProcessImpl.waitFor(Native Method) at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:151) at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:88) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:191) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:98) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:200) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAllProviders(AbstractSurefireMojo.java:177) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:135) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:98) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) "VM Thread" prio=10 tid=0x0000000006e2f000 nid=0x1fe4 runnable "GC task thread#0 (ParallelGC)" prio=6 tid=0x00000000004ac800 nid=0x1b90 runnable "GC task thread#1 (ParallelGC)" prio=6 tid=0x00000000004ae000 nid=0x11cc runnable "GC task thread#2 (ParallelGC)" prio=6 tid=0x00000000004b0000 nid=0x1244 runnable "GC task thread#3 (ParallelGC)" prio=6 tid=0x00000000004b1800 nid=0x17d8 runnable "GC task thread#4 (ParallelGC)" prio=6 tid=0x00000000004b5000 nid=0x1cbc runnable "GC task thread#5 (ParallelGC)" prio=6 tid=0x00000000004b6800 nid=0x1b14 runnable "GC task thread#6 (ParallelGC)" prio=6 tid=0x00000000004b8000 nid=0x1dc4 runnable "GC task thread#7 (ParallelGC)" prio=6 tid=0x00000000004ba000 nid=0x1ef0 runnable "VM Periodic Task Thread" prio=10 tid=0x0000000006ecc800 nid=0x184c waiting on condition JNI global references: 1110
我的测试是使用 Cucumber-JVM 设置的,并且在我尝试执行 Selenium 驱动程序的步骤定义中。我肯定会按照 selenium 网站上概述的设置步骤进行操作,但我目前对为什么该项目不通过 TeamCity 执行感到迷茫。
如果这有助于故障排除,我很乐意发送我的测试项目。任何新的见解将不胜感激!