Cannot start the driver service on http://localhost:34811/

Deleted user November 10, 2021
I'm hoping someone will offer some help here.

I tried following the similar questions asked before but no change in the results.

I'm trying to run a VS 2019 .Net 5.0 project in a bitbucket pipeline but I'm getting the following error when I try initialise a new chromeDriver (OpenQA.Selenium.WebDriverException : Cannot start the driver service on http://localhost:34811/)

Here is the copy of the yml I'm using (I've tried both the commented and uncommented version but both getting the same result)

Further information about this project is, it's a Selenium/Nunit project in c# running Cucumber feature files.

Locally I'm able to run the project in parallel but only getting issues when trying to run in the pipeline.

Any advice would greatly be appreciated :)

2 answers

0 votes
Craig Hoffman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 11, 2024

#define Selenium as a service in bitbucketpipeline file: 

definitions:
 selenium-standalone:
 image: selenium/standalone-chrome:latest
 port: 4444

 

#use it in your step

- step:
name: Unit Tests
services:
- selenium-standalone

 

#use this variable and augment with port 4444

echo $BITBUCKET_DOCKER_HOST_INTERNAL

curl -I http://$BITBUCKET_DOCKER_HOST_INTERNAL:4444

#pass this variable into the container that needs to talk to the selenium-standalone service

#set an environment variable e.g.: UTESTVAR and then use that in your test environment

#CSHARP

var options = new ChromeOptions();

options.AddArgument("--headless=new");

WebDriver driver = new RemoteWebDriver(new Uri("http://" + Environment.GetEnvironmentVariable("UTESTVAR") + ":4444"), options);

driver.Navigate().GoToUrl("http://www.google.com");

var sShot = driver.GetScreenshot();

sShot.SaveAsFile("the_screen_shot");

0 votes
Deleted user November 10, 2021

Copy of both versions of yml used:

1)

pipelines:
default:
- step:
script:
- docker version
- docker run --rm -v $(pwd)/Swoop-Acceptance:/app -w /app mcr.microsoft.com/dotnet/sdk:5.0 dotnet test --logger:trx

services:
- docker

 

 

2)

pipelines:
 default:
 - step:
 name: Build and Test
 caches:
 - dotnetcore
 services:
 - chrome
 script:
 - REPORTS_PATH=./test-reports/build_${BITBUCKET_BUILD_NUMBER}
 - dotnet build Swoop-Acceptance --configuration Debug
- dotnet test Swoop-Acceptance --configuration Debug

definitions:

services:
chrome:
image: selenium/standalone-chrome:latest
ports:
- "4444:4444

Deleted user January 27, 2022

Here is my latest version of the .yml file. Getting the same error:

image: mcr.microsoft.com/dotnet/sdk:5.0
pipelines:
default:
- step:
services:
- selenium-standalone
script: # Modify the commands below to build your repository.
- export PROJECT_NAME=Swoop-Acceptance
- export TEST_NAME=Swoop-Acceptance
- dotnet restore
- dotnet build $PROJECT_NAME
- dotnet test $TEST_NAME

definitions:
services:
selenium-standalone:
image: selenium/standalone-chrome:latest
port: 4444

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events