Skip to content

Commit

Permalink
Merge pull request #3325 from Ginger-Automation/Feature/MutiBrowserVe…
Browse files Browse the repository at this point in the history
…rsionSupport

Feature/multi browser version support
  • Loading branch information
Maheshkale447 authored Nov 1, 2023
2 parents 7e7bd93 + a316ca9 commit 03c67e6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
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 @@ public static void ClassInit(TestContext context)
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,7 +202,7 @@ public static void ClassInit(TestContext context)
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);
}
Expand Down

0 comments on commit 03c67e6

Please sign in to comment.