Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/multi browser version support #3325

Merged
merged 8 commits into from
Nov 1, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ public override string GetDriverConfigsEditPageName(Agent.eDriverType driverSubT
[UserConfiguredDescription("Only for Internet Explorer & Firefox | Set \"true\" for using 64Bit Browser")]
public bool Use64Bitbrowser { get; set; }

[UserConfigured]
[UserConfiguredDefault("")]
[UserConfiguredDescription("Use specific Version of browser. Only Testing browser versions are supported.")]
public string BrowserVersion { get; set; }

[UserConfigured]
[UserConfiguredDefault("false")]
[UserConfiguredDescription("Use Browser In Private/Incognito Mode (Please use 64bit Browse with Internet Explorer ")]
Expand Down Expand Up @@ -471,7 +476,7 @@ public override void StartDriver()
SetCurrentPageLoadStrategy(FirefoxOption);
SetBrowserLogLevel(FirefoxOption);
SetUnhandledPromptBehavior(FirefoxOption);

SetBrowserVersion(FirefoxOption);

if (HeadlessBrowserMode == true || RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Expand Down Expand Up @@ -511,7 +516,7 @@ public override void StartDriver()
SetCurrentPageLoadStrategy(options);
SetBrowserLogLevel(options);
SetUnhandledPromptBehavior(options);

SetBrowserVersion(options);
if (IsUserProfileFolderPathValid())
{
options.AddArguments("user-data-dir=" + UserProfileFolderPath);
Expand Down Expand Up @@ -571,21 +576,16 @@ public override void StartDriver()
options.AddArgument(WorkSpace.Instance.Solution.ApplitoolsConfiguration.ApiUrl);
}


ChromeDriverService ChService;
if (string.IsNullOrEmpty(DebugAddress))
{
ChService = ChromeDriverService.CreateDefaultService();
}
else
if (!string.IsNullOrEmpty(DebugAddress))
{
options.DebuggerAddress = DebugAddress.Trim();
ChService = ChromeDriverService.CreateDefaultService();

}
ChromeDriverService ChService = ChromeDriverService.CreateDefaultService();
if (HideConsoleWindow)
{
ChService.HideCommandPromptWindow = HideConsoleWindow;
}
}

try
{
Expand Down Expand Up @@ -636,7 +636,7 @@ public override void StartDriver()
ieOptions.AttachToEdgeChrome = true;
ieOptions.EdgeExecutablePath = EdgeExcutablePath;
SetBrowserLogLevel(ieOptions);

SetBrowserVersion(ieOptions);
if (EnsureCleanSession == true)
{
ieOptions.EnsureCleanSession = true;
Expand Down Expand Up @@ -684,6 +684,7 @@ public override void StartDriver()
{
EdgeOptions EDOpts = new EdgeOptions();
SetBrowserLogLevel(EDOpts);
SetBrowserVersion(EDOpts);
//EDOpts.AddAdditionalEdgeOption("UseChromium", true);
//EDOpts.UseChromium = true;
SetUnhandledPromptBehavior(EDOpts);
Expand Down Expand Up @@ -861,7 +862,7 @@ public override void StartDriver()
else if (mBrowserTpe == eBrowserType.FireFox)
{
GingerUtils.FileUtils.RenameFile(DriverServiceFileNameWithPath(FIREFOX_DRIVER_NAME), GetDriversPathPerOS());
}
}
StartDriver();
}
}
Expand Down Expand Up @@ -9810,6 +9811,21 @@ public void SetCurrentPageLoadStrategy(DriverOptions options)

}

private void SetBrowserVersion(DriverOptions options)
{
try
{
if (!string.IsNullOrWhiteSpace(BrowserVersion))
{
options.BrowserVersion = BrowserVersion;
}
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.DEBUG, "Error while setting browser version to driver options", ex);
}
}

public void SetUnhandledPromptBehavior(DriverOptions options)
{
if (UnhandledPromptBehavior == null)
Expand Down
10 changes: 5 additions & 5 deletions Ginger/GingerCoreNET/RunLib/AgentOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public async void StartDriver()
Agent.OnPropertyChanged(nameof(IsWindowExplorerSupportReady));
}
}
catch ( Exception ex)
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error occurred! While Staring Driver ", ex);
}
Expand Down Expand Up @@ -683,11 +683,11 @@ public void RunAction(Act act)
{
Driver.RunAction(act);
}
catch(Exception ex)
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, ex.Message);
}

});
}
else
Expand Down Expand Up @@ -895,9 +895,9 @@ public void Test()
{
Reporter.ToUser(eUserMsgKey.TestagentSucceed);
}
else if (Driver.ErrorMessageFromDriver != null && Driver.ErrorMessageFromDriver.Contains("Chrome driver version mismatch"))
else if (Driver.ErrorMessageFromDriver != null && Driver.ErrorMessageFromDriver.Contains("session not created: This version of "))
{
Reporter.ToUser(eUserMsgKey.FailedToConnectAgent, Agent.Name, "Chrome driver version mismatch. Please run Ginger as Admin to Auto update the chrome driver.");
Reporter.ToUser(eUserMsgKey.FailedToConnectAgent, Agent.Name, "Browser driver version mismatch. Configure the right proxy settings for auto-download in the Agent configuration, or manually download and place the driver in the Ginger installation directory.");
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
task1.Start();

Stopwatch stopwatch = Stopwatch.StartNew();
while ((mMyGingerServer == null || !mMyGingerServer.IsReady) && stopwatch.ElapsedMilliseconds < 10000)
while ((mMyGingerServer == null || !mMyGingerServer.IsReady) && stopwatch.ElapsedMilliseconds < 20000)
{
Thread.Sleep(100);
}
Expand All @@ -202,13 +202,13 @@
task2.Start();

Stopwatch stopwatch2 = Stopwatch.StartNew();
while ((mMyGingerClient == null || !mMyGingerClient.IsReady) && stopwatch2.ElapsedMilliseconds < 10000)
while ((mMyGingerClient == null || !mMyGingerClient.IsReady) && stopwatch2.ElapsedMilliseconds < 20000)
{
Thread.Sleep(100);
}
if (!mMyGingerClient.IsReady)
{
throw new Exception("Error: mMyGingerClient.IsReady false");

Check failure on line 211 in Ginger/GingerPluginCoreTest/CommunicationProtocol/GingerSocket2Test.cs

View workflow job for this annotation

GitHub Actions / Ginger MacOS UnitTests

GingerCoreNETUnitTest.Drivers.CommunicationProtocol.GingerSocket2Test ► ClientConnectSendClose

Failed test found in: Ginger/GingerPluginCoreTest/TestResults/_Mac-1698829922756_2023-11-01_09_31_04.trx Ginger/GingerPluginCoreTest/TestResults/_Mac-1698829922756_2023-11-01_09_31_04.trx Ginger/GingerPluginCoreTest/TestResults/_Mac-1698829922756_2023-11-01_09_31_04.trx Ginger/GingerPluginCoreTest/TestResults/_Mac-1698829922756_2023-11-01_09_31_04.trx Ginger/GingerPluginCoreTest/TestResults/_Mac-1698829922756_2023-11-01_09_31_04.trx Ginger/GingerPluginCoreTest/TestResults/_Mac-1698829922756_2023-11-01_09_31_04.trx Ginger/GingerPluginCoreTest/TestResults/_Mac-1698829922756_2023-11-01_09_31_04.trx Ginger/GingerPluginCoreTest/TestResults/_Mac-1698829922756_2023-11-01_09_31_04.trx Ginger/GingerPluginCoreTest/TestResults/_Mac-1698829922756_2023-11-01_09_31_04.trx Ginger/GingerPluginCoreTest/TestResults/_Mac-1698829922756_2023-11-01_09_31_04.trx Error: Class Initialization method GingerCoreNETUnitTest.Drivers.CommunicationProtocol.GingerSocket2Test.ClassInit threw exception. System.Exception: System.Exception: Error: mMyGingerClient.IsReady false.
Raw output
Class Initialization method GingerCoreNETUnitTest.Drivers.CommunicationProtocol.GingerSocket2Test.ClassInit threw exception. System.Exception: System.Exception: Error: mMyGingerClient.IsReady false.
   at GingerCoreNETUnitTest.Drivers.CommunicationProtocol.GingerSocket2Test.ClassInit(TestContext context) in /Users/runner/work/Ginger/Ginger/Ginger/GingerPluginCoreTest/CommunicationProtocol/GingerSocket2Test.cs:line 211
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
}

}
Expand Down
Loading