【发布时间】:2011-04-23 21:19:26
【问题描述】:
我正在使用 selenium-rc 和 C# 来测试我的 asp.net mvc2 应用程序。目前我正在做的就是用 selenium RC 打开主页。
当我运行测试时,我看到 selenium 遥控器在浏览器中打开,我看到我的应用程序在浏览器中正确打开,但 selenium 显示 404 错误并中止测试。
为了使这项工作正常进行,我将测试缩减为一个简单的控制台应用程序,并更改了默认的 selenium 端口,这是我的代码:
static void Main(string[] args)
{
try
{
var _selenium = new DefaultSelenium("localhost", 1234, "*chrome", "http://localhost:6666");
_selenium.Start();
_selenium.Open("/");
try
{
_selenium.Stop();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
Console.WriteLine("Done.");
Console.ReadKey();
}
失败并出现错误“XHR ERROR: URL = /localhost:6666/ Response_Code = 404 Error_Message = Not Found on session 5f2e59798ae74e7cb741d50cae7e817a”
如果您查看正在运行的 selenium 控制台,您会看到
15:53:16.238 INFO - Allocated session 5f2e59798ae74e7cb741d50cae7e817a for http://localhost:6666, launching...
15:53:16.265 INFO - Preparing Firefox profile...
15:53:18.325 INFO - Launching Firefox...
15:53:20.977 INFO - Got result: OK,5f2e59798ae74e7cb741d50cae7e817a on session 5f2e59798ae74e7cb741d50cae7e817a
15:53:20.980 INFO - Command request: open[/, ] on session 5f2e59798ae74e7cb741d50cae7e817a
15:53:22.654 INFO - Got result: XHR ERROR: URL = http://localhost:6666/ Response_Code = 404 Error_Message = Not Found on session 5f2e59798ae74e7cb741d50cae7e817a
我尝试过的有趣的事情是:
将网站更改为“google” - 然后我的测试工作
将站点更改为“google”端口 80 然后它不起作用。
将我的网站从 cassini 移到 iis 7 - 没有用
使我的网站成为 iis 7 上的默认网站,例如 http://localhost/ - 没用
我使用 fiddler 来观看会话 - 触发的所有请求都成功返回。
我尝试在启动 RC 服务器时传递 -avoidProxy 和 -ensureCleanSession。没有任何明显的区别。
如果我重新配置 selenium 以使用默认端口,我会一遍又一遍地重复以下异常(每 10 秒一次/每次不同的 sessionid)。一旦我更改了默认端口,就不会发生这种情况,但我已将其包括在内以防万一。
16:26:38.019 WARN - POST /selenium-server/driver/?seleniumStart=true&localFrameAddress=top&seleniumWindowName=&uniqueId=sel_48694&sessionId=a87b8d6a9e444a5485a5044ef6370e2d&counterToMakeURsUniqueAndSoStopPageCachingInTheBrowser=1286810798016&sequenceNumber=4115 HTTP/1.1
java.lang.RuntimeException: sessionId a87b8d6a9e444a5485a5044ef6370e2d doesn't exist; perhaps this session was already stopped?
at org.openqa.selenium.server.FrameGroupCommandQueueSet.getQueueSet(FrameGroupCommandQueueSet.java:220)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleBrowserResponse(SeleniumDriverResourceHandler.java:165)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:131)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:245)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
有人能解释一下吗?
【问题讨论】:
-
当您将它与普通端口一起使用时,您是在运行测试时遇到这些错误还是在没有运行任何测试的情况下出现这些错误?
标签: c# asp.net-mvc-2 selenium selenium-rc