I am trying to set up a .NET Core Console Application that uses Selenium Webdriver with Firefox in Docker, but I am having difficulty understanding how to actually use the official Selenium docker images.
For now the console app is just an app that tries to go to Google.com and report back successfully.
I am consistently getting the following error message when trying to create a new FirefoxDriver:
Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line (SessionNotCreated)
Here is the Dockerfile (generated by VSCode Docker extension + one line added by me, commented out now):
FROM microsoft/dotnet:2.1-runtime AS base
WORKDIR /app
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ["MyAppName.csproj", "./"]
RUN dotnet restore "./MyAppName.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "MyAppName.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "MyAppName.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
# FROM selenium/standalone-firefox-debug ## where does this go?
ENTRYPOINT ["dotnet", "MyAppName.dll"]
I've tried to insert the selenium standalone image at various points, attempted to start with '/bin/bash/' entrypoint to try and find if firefox is actually in the image (which it didn't seem to be, not on the regular locations). It still throws the exception.
Really all I want is to have firefox installed in my container so that I can run my .NET Core console app, but according to some google searches the simplest way to do this should be through the selenium images.
How do I properly use the selenium docker image?