I have a Selenium dotnetCore project that I execute against a docker image and now want to execute as part of teamcity.
I have teamcity build steps to stop and remove old docker selenium/standalone-chrome running images, steps to restore and build the test project, step to pull selenium/standalone-chrome:latest image.
Next, I have the below step which works fine for me when I run the tests from command line on my local system: docker run -e TZ=Australia/Sydney --shm-size=2g -id -v "%teamcity.build.workingDir%\TestProjectAutoTests\bin\Release\netcoreapp3.1:/tmp" -p 4445:4445 selenium/standalone-chrome
However when I execute the same through teamcity step, I get the below error:
[00:01:55][TestProjectAutoTests: TestProjectAutoTests.Tests.RegressionTestsOne.TC_01] OpenQA.Selenium.WebDriverException : An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://localhost:4445/wd/hub/session. The exception message was: Cannot assign requested address
----> System.Net.Http.HttpRequestException : Cannot assign requested address
----> System.Net.Sockets.SocketException : Cannot assign requested address
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
[00:01:55][TestProjectAutoTests: TestProjectAutoTests.Tests.RegressionTestsOne.TC_01] at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout)
I have tried with port 4444 too but I face the same issue. Can someone please help me with the above issue. Thanks.