Skip to content

Commit

Permalink
Allows browser height & width to be set manualy to a larger size than…
Browse files Browse the repository at this point in the history
… the current resolution supports. (#476)
  • Loading branch information
jlattimer authored and dtu11 committed May 17, 2019
1 parent 0a426df commit ae5aa2a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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

0 comments on commit ae5aa2a

Please sign in to comment.