Need Advice - Selenium NUnit (nunit-console) Build Step Timeout Exception

I am trying to run an automated Selenium test, using NUnit as a Build Step in TeamCity 9.1.1. I first tried using the NUnit-Runner, but couldn't get any luck with that, so I installed NUnit 2.6.4 on the build server and am launching the test with the nunit-console command.

There are 3 steps in this build configuration. 1) NuGet Restore 2) MsBuild - Build 3) Run UI Tests. This is the third build step, the other 2 work fine. Here is the 'Custom Script' in my 3rd TeamCity build step:


cd "C:\Program Files (x86)\NUnit 2.6.4\bin"
nunit-console.exe /result:test-results.xml %teamcity.build.checkoutDir%/InboundMarketing.UITests/bin/Debug/InboundMarketing.UITests.dll


The funny thing is, if I remote into the build server, and execute 'nunit-console.exe /result:test-results.xml %teamcity.build.checkoutDir%/InboundMarketing.UITests/bin/Debug/InboundMarketing.UITests.dll' manually, firefox launches, and NUnit launches the selenium tests just fine. But when I try and integrate this with TeamCity, it just bombs. I am remoted into the build server, and I never see Firefox launch, or anything. Here is the error output in my Build Log:

[12:21:03][Step 3/3] F
[12:21:03][Step 3/3] Tests run: 1, Errors: 1, Failures: 0, Inconclusive: 0, Time: 79.8372119 seconds
[12:21:03][Step 3/3] Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
[12:21:03][Step 3/3]
[12:21:03][Step 3/3] Errors and Failures:
[12:21:03][Step 3/3] 1) Test Error : InboundMarketing.UITests.BaseDriver.Login
[12:21:03][Step 3/3] OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:7064/hub/session/adf02bb3-55f8-46ff-a2da-99b368ec5a55/title timed out after 60 seconds.
[12:21:03][Step 3/3] ----> System.Net.WebException : The operation has timed out
[12:21:03][Step 3/3] at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
[12:21:03][Step 3/3] at OpenQA.Selenium.Firefox.FirefoxDriverCommandExecutor.Execute(Command commandToExecute)
[12:21:03][Step 3/3] at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
[12:21:03][Step 3/3] at OpenQA.Selenium.Remote.RemoteWebDriver.get_Title()
[12:21:03][Step 3/3] at InboundMarketing.UITests.BaseDriver.Login() in c:\TeamCity\buildAgent\work\d5658613d988090b\InboundMarketing.UITests\BaseDriver.cs:line 70
[12:21:03][Step 3/3] --WebException
[12:21:03][Step 3/3] at System.Net.HttpWebRequest.GetResponse()
[12:21:03][Step 3/3] at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)



Additionally, here is the NUnit test I'm trying to run. This is just a very simple test, to ensure the build server is going to run these, before I dig too deep into the actual coding of the UI Tests:

using System;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;

namespace InboundMarketing.UITests
{
    [TestFixture]
    public class BaseDriver
    {
        protected IWebDriver Driver;
        protected string InboundMarketingServer;
        protected string Username;
        protected string Password;

        [SetUp]
        public void Init()
        {
            InboundMarketingServer = "http://urlto.thesite.com/subsite";
            Username = "myusername";
            Password = "mypassword";

            
            var profile = new FirefoxProfile { AcceptUntrustedCertificates = true };
            Driver = new FirefoxDriver(profile);

            Driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromMinutes(1));
            Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMinutes(1));
            Driver.Navigate().GoToUrl(InboundMarketingServer);
        }

        [Test]
        public void Login()
        {
            Driver.FindElement(By.Id("txtUserName")).SendKeys(Username);
            Driver.FindElement(By.Id("txtPassword")).SendKeys(Password);
            Driver.FindElement(By.Id("chkEula")).Click();
            Driver.FindElement(By.Id("Submit")).Click();

            Assert.AreEqual(Driver.Title, "Dashboard");
        }

        [TearDown]
        public void Cleanup()
        {
            Driver.Quit();
        }
    }
}


My TeamCity BuildAgent Service and TeamCity Server Service are both running as 'LocalSystem' on the build server. The build server is Windows Server 2012 R2.

Could anyone point me in the right direction here? I feel like I have this narrowed down to being a TeamCity issue, but I can't put my finger on what exactly might be causing the problem. Thanks in advance for any help!

*Update: I added another build agent to be ran as an admin user on the build server, and tried using that user to run the build agent service, and used that build agent to run the build configuration, but that didn't fix the issue.

*Update 2: I went into the build agent temp directory, and got the generated .cmd file that the build step to run the UI tests is using, saved that as 'custom_script.cmd' INSIDE that directory, ran it, and Firefox opened up, and the UI tests executed just fine. Although at the end, there was a Windows error message stating 'plugin container for Firefox stopped working'.

Problem signature:
  Problem Event Name: APPCRASH
  Application Name: plugin-container.exe
  Application Version: 40.0.2.5702
  Application Timestamp: 55cc03bd
  Fault Module Name: mozglue.dll
  Fault Module Version: 40.0.2.5702
  Fault Module Timestamp: 55cbf190
  Exception Code: 80000003
  Exception Offset: 0000e631
  OS Version: 6.3.9600.2.0.0.272.7
  Locale ID: 1033
  Additional Information 1: 5861
  Additional Information 2: 5861822e1919d7c014bbb064c64908b2
  Additional Information 3: a10f
  Additional Information 4: a10ff7d2bb2516fdc753f9c34fc3b069
2 comments
Comment actions Permalink

I resolved this issue by running the build agent manually, rather than as a Windows Service.

Can someone from the TeamCity team confirm is this is the recommended approach?

0
Comment actions Permalink

Hello,

Sorry for delay. Yes, it is recommended to run agent via console to be able to run GUI tests. Please find more details in the related section in documentation: https://confluence.jetbrains.com/display/TCD9/Known+Issues#KnownIssues-AgentrunningasWindowsServiceLimitations.

0

Please sign in to leave a comment.