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) (#494)
  • Loading branch information
TYLEROL committed May 22, 2019
1 parent 3f8b220 commit aa071f3
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 @@ -62,8 +62,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 RemoteBrowserType { get; set; }
Expand All @@ -38,6 +40,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 @@ -48,6 +53,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 aa071f3

Please sign in to comment.