Skip to content

Commit

Permalink
Set headless option to false when Devtools are enabled (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
henkmollema authored and kblok committed Jan 3, 2019
1 parent 1dabf1f commit 82a9b33
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
21 changes: 21 additions & 0 deletions lib/PuppeteerSharp.Tests/LaunchOptionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace PuppeteerSharp.Tests
{
public class LaunchOptionsTests
{
[Fact]
public void DisableHeadlessWhenDevtoolsEnabled()
{
var options = new LaunchOptions
{
Devtools = true
};

Assert.True(options.Devtools);
Assert.False(options.Headless);
}
}
}
14 changes: 13 additions & 1 deletion lib/PuppeteerSharp/LaunchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace PuppeteerSharp
public class LaunchOptions : IBrowserOptions, IConnectionOptions
{
private string[] _ignoredDefaultArgs;
private bool _devtools;

/// <summary>
/// Whether to ignore HTTPS errors during navigation. Defaults to false.
Expand Down Expand Up @@ -62,7 +63,18 @@ public class LaunchOptions : IBrowserOptions, IConnectionOptions
/// <summary>
/// Whether to auto-open DevTools panel for each tab. If this option is true, the headless option will be set false.
/// </summary>
public bool Devtools { get; set; }
public bool Devtools
{
get => _devtools;
set
{
_devtools = value;
if (value)
{
Headless = false;
}
}
}

/// <summary>
/// Keep alive value.
Expand Down

0 comments on commit 82a9b33

Please sign in to comment.