Skip to content

Commit

Permalink
Merge pull request #45 from AutomateThePlanet/bellatrix-healenium-int…
Browse files Browse the repository at this point in the history
…egration

bellatrix-healenium-integration
  • Loading branch information
MiriamKyoseva authored Jul 9, 2024
2 parents 2bec8ac + 589fcf5 commit 5c3980d
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/Bellatrix.Web/enums/ExecutionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ public enum ExecutionType
CrossBrowserTesting,
LambdaTest,
Selenoid,
Healenium,
}
95 changes: 68 additions & 27 deletions src/Bellatrix.Web/services/WrappedWebDriverCreateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,41 +69,82 @@ public static IWebDriver Create(BrowserConfiguration executionConfiguration)
break;
case ExecutionType.Grid:
case ExecutionType.SauceLabs:
var gridUrl = ConfigurationService.GetSection<WebSettings>().ExecutionSettings.Url;
if (gridUrl == null || !Uri.IsWellFormedUriString(gridUrl.ToString(), UriKind.Absolute))
{
throw new ArgumentException("To execute your tests in WebDriver Grid mode you need to set the gridUri in the browserSettings file.");
}
var gridUrl = ConfigurationService.GetSection<WebSettings>().ExecutionSettings.Url;
if (gridUrl == null || !Uri.IsWellFormedUriString(gridUrl.ToString(), UriKind.Absolute))
{
throw new ArgumentException("To execute your tests in WebDriver Grid mode you need to set the gridUri in the browserSettings file.");
}

DebuggerPort = GetFreeTcpPort();
DebuggerPort = GetFreeTcpPort();

if (executionConfiguration.IsLighthouseEnabled && (executionConfiguration.BrowserType.Equals(BrowserType.Chrome) || executionConfiguration.BrowserType.Equals(BrowserType.ChromeHeadless)))
{
executionConfiguration.DriverOptions.AddArgument("--remote-debugging-address=0.0.0.0");
executionConfiguration.DriverOptions.AddArgument($"--remote-debugging-port={DebuggerPort}");
}
if (executionConfiguration.IsLighthouseEnabled && (executionConfiguration.BrowserType.Equals(BrowserType.Chrome) || executionConfiguration.BrowserType.Equals(BrowserType.ChromeHeadless)))
{
executionConfiguration.DriverOptions.AddArgument("--remote-debugging-address=0.0.0.0");
executionConfiguration.DriverOptions.AddArgument($"--remote-debugging-port={DebuggerPort}");
}

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var options = executionConfiguration.DriverOptions;
if (!executionConfiguration.BrowserType.Equals(BrowserType.Safari) && !executionConfiguration.BrowserType.Equals(BrowserType.Firefox))
{
options.AddLocalStatePreference("browser", new { enabled_labs_experiments = GetExperimentalOptions() });
}
options.SetLoggingPreference(LogType.Browser, LogLevel.All);
options.SetLoggingPreference("performance", LogLevel.All);
options.AddUserProfilePreference("disable-popup-blocking", "true");
options.AddUserProfilePreference("safebrowsing.enabled", "true");
options.AddArguments("--disable-dev-shm-usage");
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var options = executionConfiguration.DriverOptions;
if (!executionConfiguration.BrowserType.Equals(BrowserType.Safari) && !executionConfiguration.BrowserType.Equals(BrowserType.Firefox))
{
options.AddLocalStatePreference("browser", new { enabled_labs_experiments = GetExperimentalOptions() });
}
options.SetLoggingPreference(LogType.Browser, LogLevel.All);
options.SetLoggingPreference("performance", LogLevel.All);
options.AddUserProfilePreference("disable-popup-blocking", "true");
options.AddUserProfilePreference("safebrowsing.enabled", "true");
options.AddArguments("--disable-dev-shm-usage");

wrappedWebDriver = new RemoteWebDriver(new Uri(gridUrl), options.ToCapabilities(), TimeSpan.FromSeconds(180));
wrappedWebDriver = new RemoteWebDriver(new Uri(gridUrl), options.ToCapabilities(), TimeSpan.FromSeconds(180));

IAllowsFileDetection allowsDetection = wrappedWebDriver as IAllowsFileDetection;
if (allowsDetection != null)
{
allowsDetection.FileDetector = new LocalFileDetector();
IAllowsFileDetection allowsDetection = wrappedWebDriver as IAllowsFileDetection;
if (allowsDetection != null)
{
allowsDetection.FileDetector = new LocalFileDetector();
}

break;
}
case ExecutionType.Healenium:
{
var gridUrl = ConfigurationService.GetSection<WebSettings>().ExecutionSettings.Url;
if (gridUrl == null || !Uri.IsWellFormedUriString(gridUrl.ToString(), UriKind.Absolute))
{
throw new ArgumentException("To execute your tests in WebDriver Grid mode you need to set the gridUri in the browserSettings file.");
}

break;
DebuggerPort = GetFreeTcpPort();

if (executionConfiguration.IsLighthouseEnabled && (executionConfiguration.BrowserType.Equals(BrowserType.Chrome) || executionConfiguration.BrowserType.Equals(BrowserType.ChromeHeadless)))
{
executionConfiguration.DriverOptions.AddArgument("--remote-debugging-address=0.0.0.0");
executionConfiguration.DriverOptions.AddArgument($"--remote-debugging-port={DebuggerPort}");
}

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var options = executionConfiguration.DriverOptions;
if (!executionConfiguration.BrowserType.Equals(BrowserType.Safari) && !executionConfiguration.BrowserType.Equals(BrowserType.Firefox))
{
options.AddLocalStatePreference("browser", new { enabled_labs_experiments = GetExperimentalOptions() });
}
options.SetLoggingPreference(LogType.Browser, LogLevel.All);
options.SetLoggingPreference("performance", LogLevel.All);
options.AddUserProfilePreference("disable-popup-blocking", "true");
options.AddUserProfilePreference("safebrowsing.enabled", "true");
options.AddArguments("--disable-dev-shm-usage");
options.AddArguments("--no-sandbox");

wrappedWebDriver = new RemoteWebDriver(new Uri(gridUrl), options.ToCapabilities(), TimeSpan.FromSeconds(180));

IAllowsFileDetection allowsDetection = wrappedWebDriver as IAllowsFileDetection;
if (allowsDetection != null)
{
allowsDetection.FileDetector = new LocalFileDetector();
}

break;
}
}

var gridPageLoadTimeout = ConfigurationService.GetSection<WebSettings>().TimeoutSettings.PageLoadTimeout;
Expand Down

0 comments on commit 5c3980d

Please sign in to comment.