#docker #selenium #.net-core #selenium-chromedriver
#docker #selenium #.net-core #selenium-chromedriver
Вопрос:
Я попытался запустить драйвер Chrome в .NET Core в контейнере Docker. Возможно ли это?
Я получил это сообщение об ошибке трассировка стека:
Cannot start the driver service on http://localhost:34893/
at OpenQA.Selenium.DriverService.Start()
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions
options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options)
Мой код:
// fileName is the chromedriver file
var service = ChromeDriverService.CreateDefaultService(folderName, fileName);
var webDriver = new ChromeDriver(service, options);
Файл docker:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 6002
ENV ASPNETCORE_URLS=http:// :6002
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY . .
RUN dotnet restore "ASPNETCORE.csproj"
WORKDIR "/src/ASPNETCORE"
RUN dotnet build "ASPNETCORE.csproj" -c Release -o /app
FROM build AS publish
WORKDIR "/src/ASPNETCORE"
RUN dotnet publish "ASPNETCORE.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "ASPNETCORE.dll", "--server.urls", "http://*:6002"]
У вас есть какие-либо советы?
Комментарии:
1. пожалуйста, добавьте свой файл dockerfile
2. добавил его к вопросу