Reputation: 158
I'm using Canopy within a Docker container and would like to specify the port to 4444 instead of the final random one assigned when calling canopy.core.start because of multiple connectivity errors Error: ConnectFailure (Connection refused) --or a failure to launch the driver.
let chromeOptions = OpenQA.Selenium.Chrome.ChromeOptions()
chromeOptions.AddArgument("--no-sandbox")
chromeOptions.AddArgument("--disable-extensions")
chromeOptions.AddArgument("--disable-gpu")
chromeOptions.AddArgument("--disable-client-side-phishing-detection")
chromeOptions.AddArgument("--disable-suggestions-service")
chromeOptions.AddArgument("--safebrowsing-disable-download-protection")
chromeOptions.AddArgument("--no-first-run")
chromeOptions.AddArgument("--allow-insecure-localhost");
chromeOptions.AddArgument("--port=4444"); // Not taking effect; see below
let chromeNoSandbox = ChromeWithOptions(chromeOptions)
canopy.configuration.chromeDir <- "."
start chromeNoSandbox
Error: ConnectFailure (Connection refused) <--- Multiple of these in a docker container
Starting ChromeDriver 2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881) on port 36479 <-- How to specify this?
Upvotes: 2
Views: 522
Reputation:
There is no easy way of doing this!
How Canopy starts a WebDriver instance is by calling OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService("<path to the chromedriver executable on runner machine>")
. (Where, of course, this is true for all other browsers).
Problem is this method, according to the documentation returns a random port by definition (this is done to ensure parallel runs don't get the same port and crash. The chances of that happening are, thankfully, low).
you could try doing something like let a = OpenQA.ChromeDriverService.CreateDefaultService("<path>")
followed by a.Port <- <port number>
, but I don't know how to use the resultant WebDriverService
as the runner of our tests.
The port=4444
bit on the ChromeOptions
doesn't work because this is not a Chrome (or browser, to be general) option. It is a WebDriver one.
I posted a question on the project's tracker. Hopefully, we'll get an answer sometime soon...
Upvotes: 0