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

Add Chrome Browser Options #1384

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
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
26 changes: 18 additions & 8 deletions Microsoft.Dynamics365.UIAutomation.Browser/BrowserOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ public class BrowserOptions
{
public BrowserOptions()
{
this.TimeFactor = 1.0f;
this.DriversPath = Path.Combine(Directory.GetCurrentDirectory()); //, @"Drivers\");
this.DownloadsPath = null;
this.BrowserType = BrowserType.IE;
this.PageLoadTimeout = new TimeSpan(0, 3, 0);
this.CommandTimeout = TimeSpan.FromMinutes(20);
this.PageLoadTimeout = TimeSpan.FromMinutes(3);
this.CommandTimeout = TimeSpan.FromMinutes(5);
this.StartMaximized = true;
this.FireEvents = false;
this.TraceSource = Constants.DefaultTraceSource;
Expand Down Expand Up @@ -51,6 +52,7 @@ public BrowserOptions()
this.CookieСontrolsMode = 0;
}

public float TimeFactor { get; set; }
public BrowserType RemoteBrowserType { get; set; }
public Uri RemoteHubServer { get; set; }
public BrowserType BrowserType { get; set; }
Expand All @@ -60,7 +62,7 @@ public BrowserOptions()
public bool PrivateMode { get; set; }
public bool CleanSession { get; set; }
public TimeSpan PageLoadTimeout { get; set; }
public TimeSpan CommandTimeout { get; set; } = TimeSpan.FromMinutes(20);
public TimeSpan CommandTimeout { get; set; }
/// <summary>
/// When <see langword="true" /> the browser will open maximized at the highest supported resolution.
/// </summary>
Expand Down Expand Up @@ -104,6 +106,7 @@ public BrowserOptions()
/// Please raise any issues with this TestMode being enabled to the Microsoft/EasyRepro community on GitHub for review.
/// </summary>
public bool UCITestMode { get; set; }
public string[] ExtraChromeArguments { get; set; }

/// <summary>
/// Gets or sets the Performance Mode to enable performance center telemetry.
Expand All @@ -128,6 +131,11 @@ public virtual ChromeOptions ToChrome()
{
options.AddArgument("--incognito");
}
else
{
var tempPath = Path.GetTempPath();
options.AddArguments($"--user-data-dir={tempPath}\\EasyRepro");
}

if (this.Headless)
{
Expand Down Expand Up @@ -215,8 +223,13 @@ public virtual ChromeOptions ToChrome()
{
options.AddUserProfilePreference("download.default_directory", DownloadsPath);
}

options.AddUserProfilePreference("profile.cookie_controls_mode", this.CookieСontrolsMode);

if (ExtraChromeArguments != null)
foreach (var argument in ExtraChromeArguments)
options.AddArgument(argument);

options.AddUserProfilePreference("profile.cookie_controls_mode", this.CookieСontrolsMode);
return options;
}

Expand Down Expand Up @@ -252,10 +265,7 @@ public virtual InternetExplorerOptions ToInternetExplorer()

public virtual FirefoxOptions ToFireFox()
{
var options = new FirefoxOptions()
{

};
var options = new FirefoxOptions();

if (!string.IsNullOrEmpty(DownloadsPath))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public void NotUsing_TheBaseClass()
{
var options = TestSettings.Options;
options.PrivateMode = true;
options.TimeFactor = 1.5f;
options.ExtraChromeArguments = new[] { "--disable-geolocation" };

options.UCIPerformanceMode = false; // <= you can also change other settings here, for this tests only

var client = new WebClient(options);
Expand Down