在我使用 GhostDriver (PhantomJS) 对 Selenium 进行的第一个非常简单的测试中,测试通过了,但 PhantomJS.exe 没有退出。我在 Windows 7、PhantomJS 1.9.0、Selenium WebDriver API 2.32.1 和 NUnit 2.6.2.12296、.NET 3.5 上运行。
这是我的 C#/Nunit/WebDriver 代码:
[TestFixture]
public class Driver
{
IWebDriver driver;
[SetUp]
public void Setup()
{
driver = new PhantomJSDriver(@"D:\src\Tests\Drivers");
}
[TearDown]
public void Teardown()
{
driver.Quit();
driver.Dispose();
}
[Test]
public void GoogleSearch()
{
//Navigate to the site
driver.Navigate().GoToUrl("http://www.google.com");
Assert.AreEqual("Google", driver.Title);
}
}
以下是 PhantomJS 的所有内容:
PhantomJS is launching GhostDriver...
[INFO - 2013-04-26T16:38:56.417Z] GhostDriver - Main - running on port 64183
[INFO - 2013-04-26T16:38:56.630Z] Session [c9f2b8e0-ae8f-11e2-a7c1-159b6700bc86
] - CONSTRUCTOR - Desired Capabilities: {"browserName":"phantomjs","version":"",
"platform":"ANY"}
[INFO - 2013-04-26T16:38:56.649Z] Session [c9f2b8e0-ae8f-11e2-a7c1-159b6700bc86
] - CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":
"1.9.0","driverName":"ghostdriver","driverVersion":"1.0.3","platform":"windows-7
-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"d
atabaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":f
alse,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnab
led":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":
{"proxyType":"direct"}}
[INFO - 2013-04-26T16:38:56.701Z] SessionManagerReqHand - _postNewSessionComman
d - New Session Created: c9f2b8e0-ae8f-11e2-a7c1-159b6700bc86
[INFO - 2013-04-26T16:38:59.470Z] ShutdownReqHand - _handle - About to shutdown
但它永远不会关闭......有什么想法吗?