SpecFlow + Selenium2 + ASP.NET MVC + TeamCity not working

I have some SpecFlow features that Selenium 2 uses to automate some ASP.NET MVC 3 application user interface tests. When I run them locally, it works fine and the tests pass. After making changes to Git and pushing commits to our remote repository so that our TeamCity instance comes in, the tests run and take much longer, just to lose the next one.

Test(s) failed. OpenQA.Selenium.WebDriverException : No response from server for url http://localhost:7055/hub/session/1ada0501-154a-45f7-b0a3-487af59f7a0b/timeouts/implicit_wait 

I tried looking for various solutions with no luck finding anything remotely relevant. If someone can link to any resources that would make my life easier, feel free to share them. Or help solve this problem.

+2
source share
2 answers

I don’t know the answer, but here is the plumbing code that worked for us with the following settings:

  • TeamCity (6.0.3)
  • IIS (from a fixed virtual folder)
  • ASP.NET MVC3
  • SeleniumDotNet v2.0.3
  • Firefox driver,
  • Firefox version on the server: 3.6.17
  • TeamCity works as a local system (default)

Selenium setup:

 public static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(10); private BrowserContext() { //browser = new InternetExplorerDriver(); browser = new FirefoxDriver(); browser.Manage().Timeouts().ImplicitlyWait(DefaultTimeout); } 

Configure / disable firefox with SpecFlow events:

  [BeforeScenario] public void BeforeWebScenario() { if (!BrowserContext.IsRunning) BrowserContext.Start(); BrowserContext.Current.Browser.NavigateTo("/Test/RecreateDatabase"); BrowserContext.Current.Browser.FindElement(By.ClassName("success-message")); } [AfterScenario] public void AfterWebScenario() { if (ScenarioContext.Current.TestError != null) { Console.WriteLine("Browser page source for failing test: {0}", BrowserContext.Current.Browser.PageSource); } bool browserPerScenario; if (bool.TryParse(ConfigurationManager.AppSettings["browserPerScenario"], out browserPerScenario) && browserPerScenario) BrowserContext.Stop(); } [AfterTestRun()] public static void StopBrowser() { if (BrowserContext.IsRunning) BrowserContext.Stop(); } 
+1
source

accepting a wild guess, I think this is a criminal:

 :7055 

Most likely, you run the built-in ASP.NET development server locally and work on a more full-featured web server (most likely, IIS) on another server. If you do not have a non-standard port server running (the port mentioned above), you will fail.

What you should think about is moving from an ASP.NET development server to IIS (or IIS Express). Then you can configure the site using localhost and without a port.

0
source

All Articles