TeamCity and Selenium 2 WebDriver Recommended Configuration?

Hi all

What is the recommended configuration for running Selenium Tests from TeamCity?

At the moment I'm trying to run Selenium Tests (using WebDriver) as part of the nUnit build step, but Firefox fails to open.

Thank you

JP

4 comments
Comment actions Permalink

Ok, turns out that since I'm trying to test an ASP.Net application implemented with Forms Authentication the fact that Selenium would have to log in before running any tests was my problem.

0
Comment actions Permalink

Hi JP,

I am new in this team city integration with webdriver. Could you please help me how did you run your Selenium Tests from TeamCity?
I am using NUnit

How to implement the framework for this.

Thanks
HK

0
Comment actions Permalink

Hi. Were you able to get selenium tests to run on your build server? Do you happen to have a small working mockup test that can be run? I keep getting issues trying to run the tests. Here is a very basic test taht won't even run.

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

namespace Deployment.Tests
{
    [TestFixture]
    public class DoesinvoiceLoadTest
    {
        private IWebDriver driver;
        private StringBuilder verificationErrors;
        private string baseURL;
        private bool acceptNextAlert = true;

        [SetUp]
        public void SetupTest()
        {
            driver = new FirefoxDriver();
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
            baseURL = "http://dev.finance.portal/";
        }

        [TearDown]
        public void TeardownTest()
        {
            try
            {
                driver.Quit();
            }
            catch (Exception)
            {
                // Ignore errors if unable to close the browser
            }

        }

        [Test]
        public void TheCaseTest()
        {
            // open | / |
            driver.Navigate().GoToUrl(baseURL + "/");
            // click | link=Invoice |
            driver.FindElement(By.LinkText("Invoice")).Click();
            // type | id=InvoiceNumber | 19337
            driver.FindElement(By.Id("InvoiceNumber")).Clear();
            driver.FindElement(By.Id("InvoiceNumber")).SendKeys("19337");
            // click | id=btnGenerateInvoice |
            driver.FindElement(By.Id("btnGenerateInvoice")).Click();
            // assertText | css=h2 | Lynne Harder
            Assert.AreEqual("Lynne Harder", driver.FindElement(By.CssSelector("h2")).Text);
        }

    }
}

0
Comment actions Permalink

If anybody else has above issue.

We were creating a very small app using Visual Studio 2017, in C# with Selenium web driver Firefox and trying to integrate that into TeamCity. This all worked fine locally but when placing it into TeamCity and via the commands "Visual Studio Tests" => "VSTest" => "VSTest2017" I got the below error. 

The HTTP request to the remote WebDriver server for URL http://localhost:51668/session/e9048f87-2470-4346-b9b0-ebc3f2459f2f/element/fd935377-e7d8-4676-95e2-77419a0e3413/click timed out after 60 seconds

To fix this I found I had to change the current "FireFox" driver to "Chrome" driver and then it worked

0

Please sign in to leave a comment.