【问题标题】:Running tests with selenium webdriver > PhantomJSDriver on Teamcity windows client在 Teamcity Windows 客户端上使用 selenium webdriver > PhantomJSDriver 运行测试
【发布时间】:2015-06-23 22:48:51
【问题描述】:

我正在尝试使用 teamcity 实现运行 UI 测试。我可以使用 msbuild 部署我的 asp.net 站点,然后在下一步尝试运行使用 selenium webdriver 和 PhantomJSDriver 的 nunit 测试。如果我在构建代理上使用 nunit GUI 运行测试,它就可以工作。但是当它与 build 一起运行时,它会失败并出现以下错误。

// 测试

var driverService = PhantomJSDriverService.CreateDefaultService();
            driverService.HideCommandPromptWindow = true;
            driverService.Port = 4545;
            driverService.WebSecurity = false;

            using (var driver = new PhantomJSDriver(driverService))
            {
                driver.Navigate().GoToUrl(_rootUrl + "login.aspx");
                driver.Close();
                driver.Quit();
            }

//异常

  Test(s) failed. OpenQA.Selenium.WebDriverException : Unexpected error. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:4545
       at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
       --- End of inner exception stack trace ---
       at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
       at System.Net.HttpWebRequest.GetRequestStream()
       at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
       at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
       at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
       at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
       at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
       at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
       at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
       at OpenQA.Selenium.PhantomJS.PhantomJSDriver..ctor(PhantomJSDriverService service, PhantomJSOptions options, TimeSpan commandTimeout)
       at OpenQA.Selenium.PhantomJS.PhantomJSDriver..ctor(PhantomJSDriverService service, PhantomJSOptions options)

【问题讨论】:

    标签: c#-4.0 selenium-webdriver phantomjs teamcity


    【解决方案1】:

    异常说Selenium无法连接到服务器:

    No connection could be made because the target machine actively refused it 127.0.0.1:4545

    你确定_rootUrl 应该指向localhost吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-20
      • 1970-01-01
      • 1970-01-01
      • 2013-11-08
      • 2016-04-25
      • 2014-10-07
      • 1970-01-01
      相关资源
      最近更新 更多