C# specflow Selenium tests working fine in local (CLI and VS 2017 NUnit Runner). But failing in team city with error Could not find element

I am working on building Smoke Tests (3 tests) for our company's web portal, which is built using C#, N-Unit, Selenium and Specflow.

These smoke tests are working fine in local in Visual Studio N-Unit Runner and Command Line interface (CLI). But, when we run the same tests in TeamCity CI or in CLI from TeamCity Agent server, one or two tests failing with error, such as below.

"OpenQA.Selenium.NoSuchElementException : Could not find element by: By.CssSelector: #u_r_v_search_btn"

Appropriate web element locators are in place in the test suite and looks good when we run in local. But throwing error when we run the tests in TeamCity CI pipeline.

Below command, which is working fine in local. Same command failing in TeamCity Agent Server when we run it from CLI; With error such as "could not find element". ----> nunit3-console.exe ......\Tests\Bin\Debug\Tests.dll --noheader --where cat==smoke

Team City CI commmand statement from build log:

C:\buildAgent\tools\NUnit.Console.3.9.0\nunit3-console.exe C:\buildAgent\temp\buildTmp\eahe9vWdDNwsMCnwYM0DJIHv4X7ycBFR.nunit --result=C:\buildAgent\temp\buildTmp\eahe9vWdDNwsMCnwYM0DJIHv4X7ycBFR.nunit.xml --noheader --where cat==smoke

Can someone please provide insights to resolve this issue?

1 comment

If I'm understanding you correctly, this command fails when logging in into the agent's server, opening a shell and just trying to run it from there without using teamcity for it, is that correct?


If that's the case, then it's very likely this is an environment issue. Maybe missing a library or permissions? In this situation, this would be a question better posed to the nunit team.


If I misunderstood and only fails from teamcity, please follow this steps for the replication, collect the requested information and report it as mentioned there: https://confluence.jetbrains.com/display/TCD18/Common+Problems#CommonProblems-BuildworkslocallybutfailsormisbehavesinTeamCity


Please sign in to leave a comment.