Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,6 @@
"parameters": ["headful"],
"expectations": ["FAIL"]
},
{
"testIdPattern": "[page-click.spec.ts] *",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["headful"],
"expectations": ["FAIL"]
},
{
"testIdPattern": "[page-fill.spec.ts] *",
"platforms": ["darwin", "linux", "win32"],
Expand Down
22 changes: 19 additions & 3 deletions src/PlaywrightSharp.Tests/PageClickTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
using NUnit.Framework;
using PlaywrightSharp.Helpers;
Expand Down Expand Up @@ -261,7 +262,13 @@
Assert.That(await Page.EvaluateAsync<bool?>("result.check"), Is.Null);
await Page.ClickAsync("input#agree");
Assert.That(await Page.EvaluateAsync<bool>("result.check"), Is.True);
Assert.That(await Page.EvaluateAsync<string[]>("result.events"), Is.EqualTo(new[] {
var events = await Page.EvaluateAsync<string[]>("result.events");

Check failure on line 265 in src/PlaywrightSharp.Tests/PageClickTests.cs

View workflow job for this annotation

GitHub Actions / chromium-headless-ubuntu-latest

Use explicit type instead of 'var'

Check failure on line 265 in src/PlaywrightSharp.Tests/PageClickTests.cs

View workflow job for this annotation

GitHub Actions / style

Use explicit type instead of 'var'
if (!TestConstants.IsHeadless)
{
events = events.Where(e => e != "mouseout" && e != "mouseleave").ToArray();
}

Assert.That(events, Is.EqualTo(new[] {
"mouseover",
"mouseenter",
"mousemove",
Expand Down Expand Up @@ -549,6 +556,8 @@
document.body.style.margin = '0';
}");

// rafraf for Firefox to kick in the animation.
await Page.EvaluateAsync("() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f)))");
await Page.ClickAsync("button");
Assert.That(await Page.EvaluateAsync<string>("window.result"), Is.EqualTo("Clicked"));
Assert.That(await Page.EvaluateAsync<int>("pageX"), Is.EqualTo(300));
Expand Down Expand Up @@ -642,7 +651,14 @@
[Test, Timeout(TestConstants.DefaultTestTimeout)]
public async Task ShouldWaitForSelectToBeEnabled()
{
await Page.SetContentAsync("<select onclick=\"javascript: window.__CLICKED = true;\" disabled><option selected>Hello</option></select>");
await Page.SetContentAsync(@"
<select disabled><option selected>Hello</option></select>
<script>
document.querySelector('select').addEventListener('mousedown', event => {
window.__CLICKED=true;
event.preventDefault();
});
</script>");
var clickTask = Page.ClickAsync("select");
await GiveItAChanceToClick(Page);
Assert.That(await Page.EvaluateAsync<bool?>("window.__CLICKED"), Is.Null);
Expand Down Expand Up @@ -894,7 +910,7 @@
public async Task ShouldClickTheButtonWhenWindowInnerWidthIsCorrupted()
{
await Page.GoToAsync(TestConstants.ServerUrl + "/input/button.html");
await Page.EvaluateAsync(@"() => window.innerWith = 0");
await Page.EvaluateAsync(@"() => Object.defineProperty(window, 'innerWidth', { value: 0 })");

await Page.ClickAsync("button");
Assert.That(await Page.EvaluateAsync<string>("result"), Is.EqualTo("Clicked"));
Expand Down
2 changes: 2 additions & 0 deletions src/PlaywrightSharp.Tests/TestConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ internal static Task<IBrowser> LaunchDefaultHeadful(
internal static readonly bool IsChromium = Product.Equals(ChromiumProduct, StringComparison.OrdinalIgnoreCase);
internal static readonly bool IsMacOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
internal static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
internal static readonly bool IsHeadless = !string.Equals(
Environment.GetEnvironmentVariable("HEADLESS"), "false", StringComparison.OrdinalIgnoreCase);

public static readonly IEnumerable<string> NestedFramesDumpResult = new List<string>()
{
Expand Down
Loading