0

我目前正在连接由 CCNET 运行的 Selenium 测试,CCNET 在我们的构建服务器中作为服务运行。

这是我的Project.build文件:

<Target Name="AutomationTests">
<Message Text="~~~~~~~~~~~~~~~~$(HARD_NEW_LINE)" />
<Message Text="cmd.exe /interactive /c $(MSBuildProjectDirectory)\Nunit.bat $(SourceFolder)\Project.Web.UI.Automation\bin\Release\Project.Web.UI.Automation.dll"/>
<Exec Command="cmd.exe /interactive /c $(MSBuildProjectDirectory)\Nunit.bat /run:Project.Web.UI.Automation.Test.login $(SourceFolder)\Project.Web.UI.Automation\bin\Release\Project.Web.UI.Automation.dll" ContinueOnError="true" />
</Target>

注意:我按照本文中的建议从批处理文件中运行 Nunit 。

这是我的CCNET.config文件:

<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
<workingDirectory>C:\Projects\Project\AutomationUpdate\</workingDirectory>
<projectFile>Project.build</projectFile>
<buildArgs>/p:Configuration=Debug</buildArgs>
<targets>AutomationTests</targets>
<timeout>1800</timeout>
<logger>C:\CCNET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
</msbuild>

我的问题是,即使 Nunit 启动(我可以在 MSBUILD 日志中看到它的输出),Selenium 也会引发超时异常。这是 CCNET 中构建日志的摘录。

<message level="high"><![CDATA[ProcessModel: Default    DomainUsage: Single]]></message>
<message level="high"><![CDATA[Execution Runtime: net-4.5]]></message>
<message level="high"><![CDATA[Selected test(s): Project.Web.UI.Automation.Test.login]]></message>
<message level="high"><![CDATA[.F.F.F.F.F.F]]></message>
<message level="high"><![CDATA[Tests run: 6, Errors: 6, Failures: 0, Inconclusive: 0, Time: 223.3787765 seconds]]></message>
<message level="high"><![CDATA[  Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0]]></message>
<message level="high" />
<message level="high"><![CDATA[Errors and Failures:]]></message>
<warning file="EXEC" line="0" column="0" timeStamp="10/29/2013 12:38:16"><![CDATA[Project.Web.UI.Automation.Test.login.TestLogin.BlankPassword]]></warning>
<message level="normal"><![CDATA[The previous error was converted to a warning because the task was called with ContinueOnError=true.]]></message>
<message level="high"><![CDATA[   Selenium.SeleniumException : Timed out running command]]></message>
<message level="high"><![CDATA[   at Selenium.Internal.CommandTimer.Execute(SeleneseCommand commandToExecute, IWebDriver commandDriver, String[] commandArguments)]]></message>
<message level="high"><![CDATA[   at Selenium.WebDriverCommandProcessor.DoCommand(String command, String[] args)]]></message>
<message level="high"><![CDATA[   at Project.PageObjects.LoginPage.LoginToProject(String username, String password) in c:\Projects\Project\AutomationUpdate\Source\Project.Web.UI.Automation\PageObjects\login\LoginPage.cs:line 21]]></message>
<message level="high"><![CDATA[   at Project.Web.UI.Automation.Test.login.TestLogin.BlankPassword() in c:\Projects\Project\AutomationUpdate\Source\Project.Web.UI.Automation\Test\login\TestLogin.cs:line 60]]></message>
<message level="high" />

我在这里做错什么了吗?

编辑:
先前的错误是由于过时的 Selenium 驱动程序造成的。现在我们得到了一个不同的异常:

SetUp : OpenQA.Selenium.WebDriverException : An error occurred while connecting to Firefox
----> System.IO.IOException : The directory is not empty.
at OpenQA.Selenium.Firefox.FirefoxDriver.StartClient()
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout)
at Project.Web.UI.Automation.Test.login.TestLogin.SetUp() in c:\Projects\Project\AutomationUpdate\Source\Project.Web.UI.Automation\Test\login\TestLogin.cs:line 16
--IOException
 at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
at OpenQA.Selenium.Firefox.FirefoxExtension.Install(String profileDir)
at OpenQA.Selenium.Firefox.FirefoxProfile.InstallExtensions()
at OpenQA.Selenium.Firefox.FirefoxProfile.WriteToDisk()
at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Start()
at OpenQA.Selenium.Firefox.FirefoxDriver.StartClient()

在 CCNET 控制台下运行时,相同的代码运行完美。有任何想法吗?

4

2 回答 2

0

可能是安全问题,或者是“用户交互问题”,因为 ccnet 作为本地系统运行,它没有真正的“主”文件夹。

所以可能它找不到firefox exe,你指定了它的路径吗?或者它可能无法访问路径

您可以做几件事:

  • 以与交互方式相同的用户身份运行 ccnet 服务
  • 更改文件夹的安全性,以便本地系统可以访问它们

选项1是最简单的:-)

于 2013-10-30T06:57:38.233 回答
0

看来CCNET毕竟无法满足我的要求。这是技术上的不可能。我们选择使用另一个 CI 服务器。

于 2014-03-11T08:21:59.087 回答