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

Allows browser height & width to be set manually #476

Merged
merged 1 commit into from
May 17, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ public static IWebDriver CreateWebDriver(BrowserOptions options)

driver.Manage().Timeouts().PageLoad = options.PageLoadTimeout;

if(options.StartMaximized && options.BrowserType != BrowserType.Chrome) //Handle Chrome in the Browser Options
// StartMaximized overrides a set width & height
if (options.StartMaximized && options.BrowserType != BrowserType.Chrome) //Handle Chrome in the Browser Options
driver.Manage().Window.Maximize();
else if (!options.StartMaximized && options.Width.HasValue && options.Height.HasValue)
driver.Manage().Window.Size = new System.Drawing.Size(options.Width.Value, options.Height.Value);

if (options.FireEvents || options.EnableRecording)
{
Expand Down
13 changes: 13 additions & 0 deletions Microsoft.Dynamics365.UIAutomation.Browser/BrowserOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public BrowserOptions()
this.RecordingScanInterval = TimeSpan.FromMilliseconds(Constants.Browser.Recording.DefaultScanInterval);
this.Credentials = BrowserCredentials.Default;
this.HideDiagnosticWindow = true;
this.Height = null;
this.Width = null;
}

public BrowserType BrowserType { get; set; }
Expand All @@ -36,6 +38,9 @@ public BrowserOptions()
public bool CleanSession { get; set; }
public TimeSpan PageLoadTimeout { get; set; }
public TimeSpan CommandTimeout { get; set; }
/// <summary>
/// When <see langword="true" /> the browser will open maximized at the highest supported resolution.
/// </summary>
public bool StartMaximized { get; set; }
public bool FireEvents { get; set; }
public bool EnableRecording { get; set; }
Expand All @@ -46,6 +51,14 @@ public BrowserOptions()
public bool UserAgent { get; set; }
public string UserAgentValue { get; set; }
public int DefaultThinkTime { get; set; }
/// <summary>
/// Gets or sets the browser height when <see cref="StartMaximized"/> is <see langword="false" />. Both <see cref="Height"/> and <see cref="Width"/> must be set.
/// </summary>
public int? Height { get; set; }
/// <summary>
/// Gets or sets the browser width when Both <see cref="StartMaximized"/> is <see langword="false" />. Both <see cref="Height"/> and <see cref="Width"/> must be set.
/// </summary>
public int? Width { get; set; }

public virtual ChromeOptions ToChrome()
{
Expand Down