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:
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();
}
}
}*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 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
Please sign in to leave a comment.
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?
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.