Skip to content

Commit

Permalink
Tests - Skip failing Keyboard/Mouse tests
Browse files Browse the repository at this point in the history
Issue #8
  • Loading branch information
amaitland committed Feb 4, 2022
1 parent 3ab6c6b commit 4dc607d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 38 deletions.
54 changes: 22 additions & 32 deletions lib/PuppeteerSharp.Tests/KeyboardTests/KeyboardTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@ namespace PuppeteerSharp.Tests.KeyboardTests
[Collection(TestConstants.TestFixtureCollectionName)]
public class KeyboardTests : PuppeteerPageBaseTest
{
public KeyboardTests(ITestOutputHelper output) : base(output)
public KeyboardTests(ITestOutputHelper output) : base(output, initialUrl: TestConstants.ServerUrl + "/input/textarea.html")
{
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should type into a textarea")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldTypeIntoTheTextarea()
{
const string expected = "Type in this text!";

await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");

var textarea = await DevToolsContext.QuerySelectorAsync("textarea");

await textarea.TypeAsync(expected);
Expand All @@ -34,10 +32,9 @@ public async Task ShouldTypeIntoTheTextarea()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should move with the arrow keys")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldMoveWithTheArrowKeys()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");
await DevToolsContext.TypeAsync("textarea", "Hello World!");
Assert.Equal("Hello World!", await DevToolsContext.EvaluateExpressionAsync<string>("document.querySelector('textarea').value"));
for (var i = 0; i < "World!".Length; i++)
Expand All @@ -59,10 +56,9 @@ public async Task ShouldMoveWithTheArrowKeys()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should send a character with ElementHandle.press")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldSendACharacterWithElementHandlePress()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");
var textarea = await DevToolsContext.QuerySelectorAsync("textarea");
await textarea.PressAsync("a");
Assert.Equal("a", await DevToolsContext.EvaluateExpressionAsync<string>("document.querySelector('textarea').value"));
Expand All @@ -74,10 +70,9 @@ public async Task ShouldSendACharacterWithElementHandlePress()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "ElementHandle.press should support |text| option")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ElementHandlePressShouldSupportTextOption()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");
var textarea = await DevToolsContext.QuerySelectorAsync("textarea");
await textarea.PressAsync("a", new PressOptions { Text = "ё" });
Assert.Equal("ё", await DevToolsContext.EvaluateExpressionAsync<string>("document.querySelector('textarea').value"));
Expand All @@ -87,7 +82,6 @@ public async Task ElementHandlePressShouldSupportTextOption()
[PuppeteerFact]
public async Task ShouldSendACharacterWithSendCharacter()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");
await DevToolsContext.FocusAsync("textarea");
await DevToolsContext.Keyboard.SendCharacterAsync("");
Assert.Equal("", await DevToolsContext.EvaluateExpressionAsync<string>("document.querySelector('textarea').value"));
Expand All @@ -97,7 +91,7 @@ public async Task ShouldSendACharacterWithSendCharacter()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should report shiftKey")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldReportShiftKey()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/keyboard.html");
Expand Down Expand Up @@ -126,7 +120,7 @@ public async Task ShouldReportShiftKey()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should report multiple modifiers")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldReportMultipleModifiers()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/keyboard.html");
Expand All @@ -146,7 +140,7 @@ public async Task ShouldReportMultipleModifiers()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should send proper codes while typing")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldSendProperCodesWhileTyping()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/keyboard.html");
Expand All @@ -173,7 +167,7 @@ public async Task ShouldSendProperCodesWhileTyping()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should send proper codes while typing with shift")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldSendProperCodesWhileTypingWithShift()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/keyboard.html");
Expand All @@ -189,10 +183,9 @@ public async Task ShouldSendProperCodesWhileTypingWithShift()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should not type canceled events")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldNotTypeCanceledEvents()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");
await DevToolsContext.FocusAsync("textarea");
await DevToolsContext.EvaluateExpressionAsync(@"{
window.addEventListener('keydown', event => {
Expand All @@ -209,10 +202,9 @@ await DevToolsContext.EvaluateExpressionAsync(@"{
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should specify repeat property")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldSpecifyRepeatProperty()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");
await DevToolsContext.FocusAsync("textarea");
await DevToolsContext.EvaluateExpressionAsync("document.querySelector('textarea').addEventListener('keydown', e => window.lastEvent = e, true)");
await DevToolsContext.Keyboard.DownAsync("a");
Expand All @@ -231,26 +223,26 @@ public async Task ShouldSpecifyRepeatProperty()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should type all kinds of characters")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldTypeAllKindsOfCharacters()
{
const string expected = "This text goes onto two lines.\nThis character is 嗨.";

await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");
await DevToolsContext.FocusAsync("textarea");

await DevToolsContext.Keyboard.TypeAsync(expected);
var textarea = await DevToolsContext.QuerySelectorAsync("textarea");

var actual = await DevToolsContext.EvaluateExpressionAsync<string>("result");
await textarea.FocusAsync();

await textarea.TypeAsync(expected);

var actual = await textarea.GetPropertyValueAsync<string>("value");

Assert.Equal(expected, actual);
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should specify location")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldSpecifyLocation()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");
await DevToolsContext.EvaluateExpressionAsync(@"{
window.addEventListener('keydown', event => window.keyLocation = event.location, true);
}");
Expand Down Expand Up @@ -293,13 +285,11 @@ public async Task ShouldThrowOnUnknownKeys()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should type emoji")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldTypeEmoji()
{
const string expected = "👹 Tokyo street Japan \uD83C\uDDEF\uD83C\uDDF5";

await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");

var textArea = await DevToolsContext.QuerySelectorAsync("textarea");

await textArea.TypeAsync(expected);
Expand All @@ -310,7 +300,7 @@ public async Task ShouldTypeEmoji()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should type emoji into an iframe")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldTypeEmojiIntoAniframe()
{
const string expected = "👹 Tokyo street Japan \uD83C\uDDEF\uD83C\uDDF5";
Expand All @@ -328,7 +318,7 @@ public async Task ShouldTypeEmojiIntoAniframe()
}

[PuppeteerTest("keyboard.spec.ts", "Keyboard", "should press the metaKey")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldPressTheMetaKey()
{
await DevToolsContext.EvaluateFunctionAsync(@"() =>
Expand Down
8 changes: 4 additions & 4 deletions lib/PuppeteerSharp.Tests/MouseTests/MouseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public MouseTests(ITestOutputHelper output) : base(output)
}

[PuppeteerTest("mouse.spec.ts", "Mouse", "should click the document")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldClickTheDocument()
{
await DevToolsContext.EvaluateFunctionAsync(@"() => {
Expand Down Expand Up @@ -57,7 +57,7 @@ await DevToolsContext.EvaluateFunctionAsync(@"() => {
}

[PuppeteerTest("mouse.spec.ts", "Mouse", "should resize the textarea")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldResizeTheTextarea()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");
Expand All @@ -73,7 +73,7 @@ public async Task ShouldResizeTheTextarea()
}

[PuppeteerTest("mouse.spec.ts", "Mouse", "should select the text with mouse")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldSelectTheTextWithMouse()
{
await DevToolsContext.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html");
Expand Down Expand Up @@ -187,7 +187,7 @@ await DevToolsContext.EvaluateExpressionAsync(@"{
}

[PuppeteerTest("mouse.spec.ts", "Mouse", "should work with mobile viewports and cross process navigations")]
[PuppeteerFact]
[PuppeteerFact(Skip = "Issue https://github.com/cefsharp/Puppeteer/issues/8")]
public async Task ShouldWorkWithMobileViewportsAndCrossProcessNavigations()
{
await DevToolsContext.GoToAsync(TestConstants.EmptyPage);
Expand Down
6 changes: 4 additions & 2 deletions lib/PuppeteerSharp.Tests/PuppeteerPageBaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ namespace PuppeteerSharp.Tests
public class PuppeteerPageBaseTest : PuppeteerBaseTest, IAsyncLifetime
{
private readonly bool _ignoreHTTPSerrors;
private readonly string _initialUrl;

public PuppeteerPageBaseTest(ITestOutputHelper output, bool ignoreHTTPSerrors = true) : base(output)
public PuppeteerPageBaseTest(ITestOutputHelper output, bool ignoreHTTPSerrors = true, string initialUrl = TestConstants.ServerIpUrl) : base(output)
{
_ignoreHTTPSerrors = ignoreHTTPSerrors;
_initialUrl = initialUrl;
}

protected DevToolsContext DevToolsContext { get; set; }
Expand All @@ -23,7 +25,7 @@ public PuppeteerPageBaseTest(ITestOutputHelper output, bool ignoreHTTPSerrors =
public async Task InitializeAsync()
{
var requestContext = new RequestContext();
ChromiumWebBrowser = new ChromiumWebBrowser(TestConstants.ServerIpUrl, requestContext : requestContext);
ChromiumWebBrowser = new ChromiumWebBrowser(_initialUrl, requestContext : requestContext);

await ChromiumWebBrowser.WaitForInitialLoadAsync();

Expand Down

0 comments on commit 4dc607d

Please sign in to comment.