Skip to content

Commit 450e32a

Browse files
authored
Playwright | additional constructor for page testing (#3418)
* Playwright | additional constructor for page testing * remove redundant base * Public Api Snapshot Files
1 parent a75cd17 commit 450e32a

5 files changed

+25
-7
lines changed

TUnit.Playwright/ContextTest.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ namespace TUnit.Playwright;
55

66
public class ContextTest : BrowserTest
77
{
8+
public ContextTest()
9+
{
10+
}
11+
12+
public ContextTest(BrowserTypeLaunchOptions options) : base(options)
13+
{
14+
}
15+
816
public IBrowserContext Context { get; private set; } = null!;
917

1018
public virtual BrowserNewContextOptions ContextOptions(TestContext testContext)
1119
{
12-
return new()
13-
{
14-
Locale = "en-US",
15-
ColorScheme = ColorScheme.Light,
16-
};
20+
return new() { Locale = "en-US", ColorScheme = ColorScheme.Light, };
1721
}
1822

1923
[Before(HookType.Test, "", 0)]
@@ -23,7 +27,7 @@ public async Task ContextSetup(TestContext testContext)
2327
{
2428
throw new InvalidOperationException($"Browser is not initialized. This may indicate that {nameof(BrowserTest)}.{nameof(BrowserSetup)} did not execute properly.");
2529
}
26-
30+
2731
Context = await NewContext(ContextOptions(testContext)).ConfigureAwait(false);
2832
}
2933
}

TUnit.Playwright/PageTest.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ namespace TUnit.Playwright;
55

66
public class PageTest : ContextTest
77
{
8+
public PageTest()
9+
{
10+
}
11+
12+
public PageTest(BrowserTypeLaunchOptions options) : base(options)
13+
{
14+
}
15+
816
public IPage Page { get; private set; } = null!;
917

1018
[Before(HookType.Test, "", 0)]
@@ -14,7 +22,7 @@ public async Task PageSetup()
1422
{
1523
throw new InvalidOperationException($"Browser context is not initialized. This may indicate that {nameof(ContextTest)}.{nameof(ContextSetup)} did not execute properly.");
1624
}
17-
25+
1826
Page = await Context.NewPageAsync().ConfigureAwait(false);
1927
}
2028
}

TUnit.PublicAPI/Tests.Playwright_Library_Has_No_API_Changes.DotNet10_0.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace
1515
public class ContextTest : .BrowserTest
1616
{
1717
public ContextTest() { }
18+
public ContextTest(.BrowserTypeLaunchOptions options) { }
1819
public .IBrowserContext Context { get; }
1920
public virtual .BrowserNewContextOptions ContextOptions(.TestContext testContext) { }
2021
[.Before(., "", 0)]
@@ -33,6 +34,7 @@ namespace
3334
public class PageTest : .ContextTest
3435
{
3536
public PageTest() { }
37+
public PageTest(.BrowserTypeLaunchOptions options) { }
3638
public .IPage Page { get; }
3739
[.Before(., "", 0)]
3840
public . PageSetup() { }

TUnit.PublicAPI/Tests.Playwright_Library_Has_No_API_Changes.DotNet8_0.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace
1515
public class ContextTest : .BrowserTest
1616
{
1717
public ContextTest() { }
18+
public ContextTest(.BrowserTypeLaunchOptions options) { }
1819
public .IBrowserContext Context { get; }
1920
public virtual .BrowserNewContextOptions ContextOptions(.TestContext testContext) { }
2021
[.Before(., "", 0)]
@@ -33,6 +34,7 @@ namespace
3334
public class PageTest : .ContextTest
3435
{
3536
public PageTest() { }
37+
public PageTest(.BrowserTypeLaunchOptions options) { }
3638
public .IPage Page { get; }
3739
[.Before(., "", 0)]
3840
public . PageSetup() { }

TUnit.PublicAPI/Tests.Playwright_Library_Has_No_API_Changes.DotNet9_0.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace
1515
public class ContextTest : .BrowserTest
1616
{
1717
public ContextTest() { }
18+
public ContextTest(.BrowserTypeLaunchOptions options) { }
1819
public .IBrowserContext Context { get; }
1920
public virtual .BrowserNewContextOptions ContextOptions(.TestContext testContext) { }
2021
[.Before(., "", 0)]
@@ -33,6 +34,7 @@ namespace
3334
public class PageTest : .ContextTest
3435
{
3536
public PageTest() { }
37+
public PageTest(.BrowserTypeLaunchOptions options) { }
3638
public .IPage Page { get; }
3739
[.Before(., "", 0)]
3840
public . PageSetup() { }

0 commit comments

Comments
 (0)