Starting Selenium EdgeDriver from Jenkins job on ECS machine

mnxl 20 Reputation points
2024-05-26T15:23:27.9466667+00:00

This is my C# script to initialise the EdgeDriver I am using to automate my WebView2 (I did not use EdgeDriverManager, since the driverManager had issues installing the edgeDriver compatible to the browser)

        public IWebDriver InitializeEdgeDriver()
        {            
            string webView2Args = Environment.GetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS");
            Console.WriteLine($"WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS: {webView2Args}");   //checked that remote-debugging-port flag is set in env variable 
            var edgeService = EdgeDriverService.CreateDefaultService();
            edgeService.Start();
            var edgeOptions = new EdgeOptions();
            edgeOptions.UseWebView = UseWebView;
            edgeOptions.DebuggerAddress = DebuggerAddress;
            foreach (var argument in IDSDKUIAutomationConfig.EdgeDriver.Arguments)
            {
                edgeOptions.AddArgument(argument);
            }
            return new EdgeDriver(@"C:\Users\admin\Desktop\msedgedriver.exe", edgeOptions);
        }

I am able to run the same script locally without issues, but when I run it though a Jenkins pipeline job, I receive the error below in the logs:

Starting Microsoft Edge WebDriver 125.0.2535.67 (626a82df5fa7d0d88fbb990d069c0dd83672d0dc) on port 57920
To submit feedback, report a bug, or suggest new features, please visit https://github.com/MicrosoftEdge/EdgeWebDriver
Only local connections are allowed.
Please see https://aka.ms/WebDriverSecurity for suggestions on keeping Microsoft Edge WebDriver safe.
Microsoft Edge WebDriver was started successfully.
Starting Microsoft Edge WebDriver 124.0.2478.51 (e23a9b7d0a14cd45f7a5324b61f0c57561757bb3) on port 57932
To submit feedback, report a bug, or suggest new features, please visit https://github.com/MicrosoftEdge/EdgeWebDriver
Only local connections are allowed.
Please see https://aka.ms/WebDriverSecurity for suggestions on keeping Microsoft Edge WebDriver safe.
Microsoft Edge WebDriver was started successfully.
Unhandled exception. OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:57932/session timed out after 60 seconds.
 ---> System.Threading.Tasks.TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 60 seconds elapsing.
 ---> System.TimeoutException: The operation was canceled.
 ---> System.Threading.Tasks.TaskCanceledException: The operation was canceled.
 ---> System.IO.IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
 ---> System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
   --- End of inner exception stack trace ---
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
   at System.Net.Http.HttpConnection.InitialFillAsync(Boolean async)
   at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpClient.HandleFailure(Exception e, Boolean telemetryStarted, HttpResponseMessage response, CancellationTokenSource cts, CancellationToken cancellationToken, CancellationTokenSource pendingRequestsCts)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
   at OpenQA.Selenium.Remote.HttpCommandExecutor.<>c__DisplayClass33_0.<<Execute>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
   --- End of inner exception stack trace ---
   at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
   at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
   at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.WebDriver.StartSession(ICapabilities capabilities)
   at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
   at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
   at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout)
   at OpenQA.Selenium.Edge.EdgeDriver..ctor(String edgeDriverDirectory, EdgeOptions options, TimeSpan commandTimeout)
   at OpenQA.Selenium.Edge.EdgeDriver..ctor(String edgeDriverDirectory, EdgeOptions options)
   at UIAutomation.AutomationActions.InitializeEdgeDriver() in E:\ui_tests\builds\scripts\win\
UIAutomation
\IMScreenAutomation\AutomationActions.cs:line 69
   at IDSDKUIAutomation.IMScreenAutomation.<Main>g__Test2|3_1() in 
E:\ui_tests\builds\scripts\win\UIAutomation\IMScreenAutomation\IMScreenAutomation.cs:line 48
   at IDSDKUIAutomation.IMScreenAutomation.Main(String[] args) in 
E:\ui_tests\builds\scripts\win\UIAutomation\IMScreenAutomation\IMScreenAutomation.cs:line 27

From the logs, I believe the WebDriver was started correctly but timed out. Two web drivers are started, 124.0.2478.51 and 125.0.2535.67 on different ports. Why is that so?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,179 questions
{count} votes