You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a testautomation framework which is working fine on my own system. It uses drivermanager to fetch the right version of msedgedriver.exe and then is supposed to launch edge and starts testing with the scripts. This works fine on my own laptop.
This code is now on a server of a client of mine. The server has Windows Server 2019 installed and is behind a proxy.The user has local administrator rights. On this server, when I launch a test with VS 2022 msedgedriver.exe starts (taskmanager) but the test fails:
The msedgedriver.exe is reachable through edge on http://localhost:53325/ (or any other port it starts) but Edge itself never starts.
The code used to start:
var edgeOptions = new EdgeOptions();
edgeOptions.Proxy = proxy;
edgeOptions.SetLoggingPreference(LogType.Driver, LogLevel.All);
edgeOptions.AddArguments("--no-sandbox");
var service = EdgeDriverService.CreateDefaultService();
service.UseVerboseLogging = true;
edgeOptions.AddUserProfilePreference("download.default_directory", Settings.DownloadFolder);
Driver = new EdgeDriver(service, edgeOptions);
What we've already tried:
Running VS 2022 in admin modus
Adding HTTP_PROXY, HTTPS_PROXY and NO_PROXY to the system variables with HTTP_PROXY and HTTPS_PROXY filled with the proxy server and NO_PROXY filled with localhost and 127.0.0.1
Checked whether msedgedriver is already running or is started multiple times. This is not the case.
Added proxyserver in the code, even for the DriverManager. This should not be the issue since msedgedriver is downloaded correctly and DriverManager takes the HTTP_PROXY and HTTPS_PROXY values from the system.
Dismissing the DriverManager and integrating the correct driver (and starting it) directly
Point 5 with Chrome instead of edge which results in the exact same error
Driver versioning combined with the version of the driver is correct
Windows firewall has been killed in the hopes that that was blocking something
Added the DeveloperToolsAvailability variable to the registry wity value "1" so that developertools is enabled for MSEdge
Minimized the code to putting msedgedriver.exe locally and added it into the PATH variables and just use this as code:
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
using Xunit;
namespace SeleniumTestProject
{
public class BlankSeleniumTest
{
private IWebDriver _driver;
public BlankSeleniumTest()
{
_driver = new EdgeDriver();
}
[Fact]
public void Test1()
{
_driver.Navigate().GoToUrl("https://URL/");
}
}
}
We are kind of clueless since the same code is working on my own system and on another server of my own. But it seems that at the client there is something configured that is blocking the start of the browser, whether it is Chrome or Edge. My take is that either the start of the browser is blocked, or the communication with the driver (which apparently is running since I can see it in edge and chrome (the localhost: is reachable).
But with everything we have already tried we are kind of in the dark.
It feels as as if there might be something in GPO rights that is allowing us to start the msedgedriver.exe (or chromedriver.exe for the same matter) but that it is preventing us to communicate with it from the test itself.
We cannot find any documentation stating what might be the issue here.
I dove into this further and came across the following code which checks whether the start of the driver was succesfull (part of OpenQA.Selenium.DriverService):
protected virtual bool IsInitialized
{
get
{
bool result = false;
try
{
HttpClient httpClient = new HttpClient();
try
{
httpClient.DefaultRequestHeaders.ConnectionClose = true;
httpClient.Timeout = TimeSpan.FromSeconds(5.0);
Uri serviceHealthUri = new Uri(ServiceUrl, new Uri(DriverCommand.Status, UriKind.Relative));
using HttpResponseMessage httpResponseMessage = Task.Run(async () => await httpClient.GetAsync(serviceHealthUri)).GetAwaiter().GetResult();
result = httpResponseMessage.StatusCode == HttpStatusCode.OK && httpResponseMessage.Content.Headers.ContentType!.MediaType!.StartsWith("application/json", StringComparison.OrdinalIgnoreCase);
return result;
}
finally
{
if (httpClient != null)
{
((IDisposable)httpClient).Dispose();
}
}
}
catch (Exception ex) when (ex is HttpRequestException || ex is TaskCanceledException)
{
Console.WriteLine(ex.Message);
return result;
}
}
}
What i've done next is I fixated the portnumber, created a powershell script doing practically the same as the above. It it sais (even before the test fails with the error OpenQA.Selenium.WebDriverException : Cannot start the driver service on http://localhost:5588/) that it is running.
The powershell script that I am running simultaniously from the developer powershell in Visual Studio:
# Set the URL for the WebDriver service status check
$serviceUrl = "http://localhost:5588/status"
# Attempt to make an HTTP GET request to the service URL
try {
$response = Invoke-WebRequest -Uri $serviceUrl -TimeoutSec 5
# Check if the response is successful (status code 200)
if ($response.StatusCode -eq 200) {
# Check the content type (case-insensitive)
$contentType = $response.Headers["Content-Type"]
if ($contentType -eq "application/json" -or $contentType -ilike "application/json*") {
Write-Host "WebDriver service is running and responsive."
} else {
Write-Host "Unexpected content type: $contentType"
}
} else {
Write-Host "Error: $($response.StatusCode)"
}
} catch {
Write-Host "Error: $_"
}
echo $response.StatusCode
Which results in the following response:
WebDriver service is running and responsive.
200
Apparently the check which is being done from the code is not able to reach http://localhost:5588 ??
AB#48961740
The text was updated successfully, but these errors were encountered:
TricTracT
changed the title
Running EdgeDriver on a protected server
Not able to communicate with EdgeDriver on a protected server, it starts, but tests say it did not start
Dec 6, 2023
Hi @TricTracT , it sounds like you are able to reach the Edge WebDriver server when launching it manually and then connecting to it through a simple script.
From a quick glance at the Selenium source code, it looks like the problem you are seeing, "Cannot start the driver service on ###", is logged when the driver process never even starts:
Thanks for your reply. The thing is, selenium is actually launching the webdriver and from visual studio it is reachable through a powershell script (by using the developer powershell console) and by using the webbrowser. I am using the same check as selenium does in the driverservice. So somehow selenium is not able to reach the service on localhost, but the powershell script (which is also ran from visual studio) is able to reach it.
So what would be the difference in policies that might affect selenium, but does not affect powershell?
So what the webdriver does is this check:
Uri serviceHealthUri = new Uri(this.ServiceUrl, new Uri(DriverCommand.Status, UriKind.Relative));
using (var response = Task.Run(async () => await httpClient.GetAsync(serviceHealthUri)).GetAwaiter().GetResult())
{
// Checking the response from the 'status' end point. Note that we are simply checking
// that the HTTP status returned is a 200 status, and that the resposne has the correct
// Content-Type header. A more sophisticated check would parse the JSON response and
// validate its values. At the moment we do not do this more sophisticated check.
isInitialized = response.StatusCode == HttpStatusCode.OK && response.Content.Headers.ContentType.MediaType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase);
}
That HTTP 200 check I've build in powershell and when I execute it at the moment the test is running (and I see the webdriver is started) it gets an HTTP 200 back. Whilst the test in VS crashes moments later (+/- 5 seconds) with the error that it cannot start the driver service. But it did start :-(
We have a testautomation framework which is working fine on my own system. It uses drivermanager to fetch the right version of msedgedriver.exe and then is supposed to launch edge and starts testing with the scripts. This works fine on my own laptop.
This code is now on a server of a client of mine. The server has Windows Server 2019 installed and is behind a proxy.The user has local administrator rights. On this server, when I launch a test with VS 2022 msedgedriver.exe starts (taskmanager) but the test fails:
The msedgedriver.exe is reachable through edge on http://localhost:53325/ (or any other port it starts) but Edge itself never starts.
The code used to start:
What we've already tried:
We are kind of clueless since the same code is working on my own system and on another server of my own. But it seems that at the client there is something configured that is blocking the start of the browser, whether it is Chrome or Edge. My take is that either the start of the browser is blocked, or the communication with the driver (which apparently is running since I can see it in edge and chrome (the localhost: is reachable).
But with everything we have already tried we are kind of in the dark.
It feels as as if there might be something in GPO rights that is allowing us to start the msedgedriver.exe (or chromedriver.exe for the same matter) but that it is preventing us to communicate with it from the test itself.
We cannot find any documentation stating what might be the issue here.
I dove into this further and came across the following code which checks whether the start of the driver was succesfull (part of OpenQA.Selenium.DriverService):
What i've done next is I fixated the portnumber, created a powershell script doing practically the same as the above. It it sais (even before the test fails with the error OpenQA.Selenium.WebDriverException : Cannot start the driver service on http://localhost:5588/) that it is running.
The powershell script that I am running simultaniously from the developer powershell in Visual Studio:
Which results in the following response:
Apparently the check which is being done from the code is not able to reach http://localhost:5588 ??
AB#48961740
The text was updated successfully, but these errors were encountered: