I am trying to run selenium tests in docker container on azure pipelines. I used .net 6.0 sdk image and then install chrome with cromedriver on it, then I run dotnet test
command. The main problem is that locally everything works good, but when I'm trying to run docker commands an azure pipelines it fails on chromedriver level.
//Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:6.0
RUN apt-get update && \
apt-get install -y gnupg wget curl unzip --no-install-recommends && \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list && \
apt-get update -y && \
apt-get install -y google-chrome-stable && \
CHROMEVER=$(google-chrome --product-version | grep -o "[^\.]*\.[^\.]*\.[^\.]*") && \
DRIVERVER=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROMEVER") && \
wget -q --continue -P /chromedriver "http://chromedriver.storage.googleapis.com/$DRIVERVER/chromedriver_linux64.zip" && \
unzip /chromedriver/chromedriver* -d /chromedriver
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "test", "<path_to_dll_with_tests>"]
//YAML
resources:
pipelines:
- pipeline: build-pipline
source: <source_pipline>
steps:
- download: build-pipline
- task: DockerInstaller@0
inputs:
dockerVersion: '20.10.12'
- task: CmdLine@2
displayName: Compose
continueOnError: true
inputs:
script: |
cd $(PIPELINE.WORKSPACE)/build-pipline/drop
docker build -t selenium-test .
docker run selenium-test
//Stacktrace from pipline logs
Starting test execution, please wait...
2022-03-21T06:54:50.0278687Z A total of 1 test files matched the specified pattern.
2022-03-21T06:54:51.3465055Z Starting ChromeDriver 99.0.4844.51 (d537ec02474b5afe23684e7963d538896c63ac77-refs/branch-heads/4844@{#875}) on port 37031
2022-03-21T06:54:51.3465695Z Only local connections are allowed.
2022-03-21T06:54:51.3466472Z Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
2022-03-21T06:54:51.3482313Z ChromeDriver was started successfully.
2022-03-21T06:57:01.7882945Z Failed LoginPage_VerifyAuthentication [2 m 11 s]
2022-03-21T06:57:01.7889798Z Error Message:
2022-03-21T06:57:01.7894880Z Test method threw exception:
2022-03-21T06:57:01.7897410Z OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:37031/session/2b0f7ffea479bcc5081fd432b3a25ffc/url timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out.
2022-03-21T06:57:01.7902422Z Stack Trace:
2022-03-21T06:57:01.7927923Z at System.Net.HttpWebRequest.GetResponse()
2022-03-21T06:57:01.7929159Z at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
2022-03-21T06:57:01.7930351Z --- End of inner exception stack trace ---
2022-03-21T06:57:01.7931075Z at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
2022-03-21T06:57:01.7932035Z at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
2022-03-21T06:57:01.7932809Z at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
2022-03-21T06:57:01.7933606Z at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
2022-03-21T06:57:01.7934397Z at OpenQA.Selenium.Remote.RemoteWebDriver.set_Url(String value)
2022-03-21T06:57:01.7935048Z at OpenQA.Selenium.Remote.RemoteNavigator.GoToUrl(Uri url)
2022-03-21T06:57:01.7935671Z at Atata.AtataNavigator.Navigate(Uri uri)
2022-03-21T06:57:01.7936240Z at Atata.AtataNavigator.ToUrl(String url)
2022-03-21T06:57:01.7936815Z at Atata.Go.ToUrl(String url)
2022-03-21T06:57:01.7937339Z at Atata.PageObject`1.Navigate()
2022-03-21T06:57:01.7937881Z at Atata.PageObject`1.Init()
2022-03-21T06:57:01.7938503Z at Atata.AtataNavigator.GoToInitialPageObject[T](T pageObject, GoOptions options)
2022-03-21T06:57:01.7939185Z at Atata.AtataNavigator.To[T](T pageObject, GoOptions options)
2022-03-21T06:57:01.7939909Z at Atata.AtataNavigator.To[T](T pageObject, String url, Boolean navigate, Boolean temporarily)
2022-03-21T06:57:01.7940650Z at Atata.Go.To[T](T pageObject, String url, Boolean navigate, Boolean temporarily)
2022-03-21T06:57:01.7943499Z
2022-03-21T06:57:01.7958978Z Standard Output Messages:
2022-03-21T06:57:01.7961938Z Cannot assign requested address [::1]:37031 (localhost:37031)
2022-03-21T06:57:01.7962160Z
2022-03-21T06:57:01.7962238Z
2022-03-21T06:57:01.7978067Z
Thanks in advance for any help.