Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ limitations under the License.
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

Expand Down Expand Up @@ -159,7 +160,7 @@ private void GetHubFilesButton_Click(object sender, RoutedEventArgs e)
Process.Start(new System.Diagnostics.ProcessStartInfo() { FileName = targetZipPath, UseShellExecute = true });
}

private void GetNodeFilesButton_Click(object sender, RoutedEventArgs e)
private async void GetNodeFilesButton_Click(object sender, RoutedEventArgs e)
{
//Getting the Ginger execution path
string? assemblyLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
Expand Down Expand Up @@ -192,7 +193,7 @@ private void GetNodeFilesButton_Click(object sender, RoutedEventArgs e)
{
BrowserType = WebBrowserType.Chrome
};
string chromeSourceFile = seleniumDriver.GetDriverPath(SeleniumDriver.eBrowserType.Chrome);
string chromeSourceFile = await seleniumDriver.GetDriverPath(SeleniumDriver.eBrowserType.Chrome);
string chromeDestFile = System.IO.Path.Combine(targetPath, chromeDriverFile);

if (!System.IO.File.Exists(chromeDestFile))
Expand All @@ -208,7 +209,7 @@ private void GetNodeFilesButton_Click(object sender, RoutedEventArgs e)

}
seleniumDriver.BrowserType = WebBrowserType.FireFox;
string fireFoxSourceFile = seleniumDriver.GetDriverPath(SeleniumDriver.eBrowserType.FireFox);
string fireFoxSourceFile = await seleniumDriver.GetDriverPath(SeleniumDriver.eBrowserType.FireFox);
string fireFoxDestFile = System.IO.Path.Combine(targetPath, fireFoxDriverFile);

if (!System.IO.File.Exists(fireFoxDestFile))
Expand All @@ -224,7 +225,7 @@ private void GetNodeFilesButton_Click(object sender, RoutedEventArgs e)
}
}
seleniumDriver.BrowserType = WebBrowserType.InternetExplorer;
string IESourceFile = seleniumDriver.GetDriverPath(SeleniumDriver.eBrowserType.IE);
string IESourceFile = await seleniumDriver.GetDriverPath(SeleniumDriver.eBrowserType.IE);
string IEDestFile = System.IO.Path.Combine(targetPath, IEDriverFile);

if (!System.IO.File.Exists(IEDestFile))
Expand All @@ -239,7 +240,7 @@ private void GetNodeFilesButton_Click(object sender, RoutedEventArgs e)
}
}
seleniumDriver.BrowserType = WebBrowserType.Edge;
string edgeSourceFile = seleniumDriver.GetDriverPath(SeleniumDriver.eBrowserType.Edge);
string edgeSourceFile = await seleniumDriver.GetDriverPath(SeleniumDriver.eBrowserType.Edge);
string edgeDestFile = System.IO.Path.Combine(targetPath, EdgeDriverFile);

if (!System.IO.File.Exists(edgeDestFile))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ public void zz()

ObservableList<MyRepositoryItem> allMRIs = mSolutionRepository.GetAllRepositoryItems<MyRepositoryItem>();
t1Count = allMRIs.Count;

//Assert
Assert.AreEqual(106, t1Count);
}

// run two threads which does GetAllitems
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ limitations under the License.
using System.Threading;
using System.Threading.Tasks;
using static GingerCoreNET.GeneralLib.General;
using DevToolsDomains = OpenQA.Selenium.DevTools.V139.DevToolsSessionDomains;
using DevToolsVersion = OpenQA.Selenium.DevTools.V139;
using DevToolsDomains = OpenQA.Selenium.DevTools.V145.DevToolsSessionDomains;
using DevToolsVersion = OpenQA.Selenium.DevTools.V145;



Expand Down Expand Up @@ -603,7 +603,7 @@ public override void StartDriver()
{
Kind = ProxyKind.Manual,
HttpProxy = Proxy,
FtpProxy = Proxy,
//FtpProxy = Proxy,
SslProxy = Proxy,
SocksProxy = Proxy,
SocksVersion = 5
Expand Down Expand Up @@ -664,7 +664,7 @@ public override void StartDriver()
}
mProxy.Kind = ProxyKind.Manual;
mProxy.HttpProxy = Proxy;
mProxy.FtpProxy = Proxy;
//mProxy.FtpProxy = Proxy;
mProxy.SslProxy = Proxy;
mProxy.SocksProxy = Proxy;

Expand Down Expand Up @@ -1160,7 +1160,7 @@ public override void StartDriver()
ex.Message.StartsWith("error starting process", StringComparison.InvariantCultureIgnoreCase)))
{
RestartRetry = false;
UpdateDriver(mBrowserType);
UpdateDriver(mBrowserType).ConfigureAwait(true);
StartDriver();
}
}
Expand Down Expand Up @@ -1319,7 +1319,7 @@ private static bool GetIsRunningInDocker()
return env == "docker";
}

private string UpdateDriver(eBrowserType browserType)
private async Task<string> UpdateDriver(eBrowserType browserType)
{
try
{
Expand Down Expand Up @@ -1364,7 +1364,7 @@ private string UpdateDriver(eBrowserType browserType)

SetBrowserVersion(driverOptions);
var driverFinder = new DriverFinder(driverOptions);
var driverpath = driverFinder.GetDriverPath();
var driverpath = await driverFinder.GetDriverPathAsync();
Reporter.ToLog(eLogLevel.INFO, $"Updated {browserType} driver to latest and placed in {driverpath}.");
return driverpath;
}
Expand All @@ -1379,10 +1379,9 @@ private string UpdateDriver(eBrowserType browserType)
}
}

public string GetDriverPath(eBrowserType browserType)
public async Task<string> GetDriverPath(eBrowserType browserType)
{
string DriverPath = string.Empty;
DriverPath = UpdateDriver(browserType);
string DriverPath = await UpdateDriver(browserType);
return DriverPath;
Comment on lines +1382 to 1385

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# List all current call sites for the newly-async APIs and highlight usages that are not obviously awaited.
rg -n -C2 '\b(GetDriverPath|UpdateDriver)\s*\(' --glob '*.cs'

printf '\nPotentially synchronous call sites:\n'
rg -nP --glob '*.cs' '^(?!.*\b(await|GetAwaiter\s*\(\)\.GetResult\s*\(\)|\.Result\b)).*\b(GetDriverPath|UpdateDriver)\s*\('

Repository: Ginger-Automation/Ginger

Length of output: 8176


Fix incomplete async migration: GetDriverPath and UpdateDriver have synchronous callers that will fail to compile and cause runtime races.

GetDriverPath and UpdateDriver are now async (Task<string>), but two categories of callers were not updated:

  1. Test compilation errors in GetDriverPathTest.cs (lines 39, 47, 55): Test methods assign the result directly to string without await:

    string DriverPath = driver.GetDriverPath(SeleniumDriver.eBrowserType.Chrome);
  2. Fire-and-forget race condition in SeleniumDriver.cs (line 1163): Within an exception handler before retry, UpdateDriver(mBrowserType) is called without await:

    UpdateDriver(mBrowserType);
    StartDriver();

    This will not wait for the driver update to complete before attempting to start the driver.

Either revert these methods to synchronous signatures or update all callers to properly await the results.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs`
around lines 1382 - 1385, GetDriverPath and UpdateDriver were converted to async
Task<string> but callers remain synchronous; update all callers to await the
async results or revert signatures. Specifically, in tests (GetDriverPathTest.cs
where lines assign string DriverPath = driver.GetDriverPath(...)) change those
to await the async call and make the test methods async, and in SeleniumDriver
exception path (where UpdateDriver(mBrowserType) is invoked before
StartDriver()) await UpdateDriver(mBrowserType) so the driver update completes
before calling StartDriver(); ensure any call sites that expect a string now use
await and propagate async up the call chain or change the methods back to
synchronous signatures consistently.

}
private static void CloseDriverProcess(DriverService driverService)
Expand Down
1 change: 0 additions & 1 deletion Ginger/GingerCoreNET/GeneralLib/GingerPlayUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ limitations under the License.
using Amdocs.Ginger.Common;
using Amdocs.Ginger.Common.External.Configurations;
using Amdocs.Ginger.CoreNET.External.GingerPlay;
using OpenQA.Selenium.DevTools.V137.Audits;
using System;

namespace GingerCoreNET.GeneralLib
Expand Down
4 changes: 2 additions & 2 deletions Ginger/GingerCoreNET/GingerCoreNET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@
<PackageReference Include="protobuf-net.Core" Version="3.2.56" />
<PackageReference Include="Protractor" Version="1.0.0" />
<PackageReference Include="RestSharp" Version="112.0.0" />
<PackageReference Include="Selenium.Support" Version="4.35.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.35.0" />
<PackageReference Include="Selenium.Support" Version="4.41.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.41.0" />
<PackageReference Include="Selenium.WebDriver.Extensions" Version="4.1.0" />
<PackageReference Include="SharpAdbClient" Version="2.3.23" />
<PackageReference Include="SkiaSharp" Version="3.116.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
using GingerCore.Drivers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using System.Threading.Tasks;

namespace GingerCoreNETUnitTest.SeleniumDriverTest
{
Expand All @@ -34,25 +35,25 @@ public void TestInitialize()
}

[TestMethod]
public void GetchromeDriverPath()
public async Task GetchromeDriverPath()
{
string DriverPath = driver.GetDriverPath(SeleniumDriver.eBrowserType.Chrome);
string DriverPath = await driver.GetDriverPath(SeleniumDriver.eBrowserType.Chrome);
bool v = File.Exists(DriverPath);
Assert.AreEqual(true, v);
}

[TestMethod]
public void GetFirfoxDriverPath()
public async Task GetFirfoxDriverPath()
{
string DriverPath = driver.GetDriverPath(SeleniumDriver.eBrowserType.FireFox);
string DriverPath = await driver.GetDriverPath(SeleniumDriver.eBrowserType.FireFox);
bool v = File.Exists(DriverPath);
Assert.AreEqual(true, v);
}

[TestMethod]
public void GetEdgexDriverPath()
public async Task GetEdgexDriverPath()
{
string DriverPath = driver.GetDriverPath(SeleniumDriver.eBrowserType.Edge);
string DriverPath = await driver.GetDriverPath(SeleniumDriver.eBrowserType.Edge);
bool v = File.Exists(DriverPath);
Assert.AreEqual(true, v);
}
Expand Down
Loading