Skip to content
Merged
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
16 changes: 10 additions & 6 deletions TUnit.Playwright/ContextTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ namespace TUnit.Playwright;

public class ContextTest : BrowserTest
{
public ContextTest()
{
}

public ContextTest(BrowserTypeLaunchOptions options) : base(options)
{
}

public IBrowserContext Context { get; private set; } = null!;

public virtual BrowserNewContextOptions ContextOptions(TestContext testContext)
{
return new()
{
Locale = "en-US",
ColorScheme = ColorScheme.Light,
};
return new() { Locale = "en-US", ColorScheme = ColorScheme.Light, };
}

[Before(HookType.Test, "", 0)]
Expand All @@ -23,7 +27,7 @@ public async Task ContextSetup(TestContext testContext)
{
throw new InvalidOperationException($"Browser is not initialized. This may indicate that {nameof(BrowserTest)}.{nameof(BrowserSetup)} did not execute properly.");
}

Context = await NewContext(ContextOptions(testContext)).ConfigureAwait(false);
}
}
10 changes: 9 additions & 1 deletion TUnit.Playwright/PageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ namespace TUnit.Playwright;

public class PageTest : ContextTest
{
public PageTest()
{
}

public PageTest(BrowserTypeLaunchOptions options) : base(options)
{
}

public IPage Page { get; private set; } = null!;

[Before(HookType.Test, "", 0)]
Expand All @@ -14,7 +22,7 @@ public async Task PageSetup()
{
throw new InvalidOperationException($"Browser context is not initialized. This may indicate that {nameof(ContextTest)}.{nameof(ContextSetup)} did not execute properly.");
}

Page = await Context.NewPageAsync().ConfigureAwait(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace
public class ContextTest : .BrowserTest
{
public ContextTest() { }
public ContextTest(.BrowserTypeLaunchOptions options) { }
public .IBrowserContext Context { get; }
public virtual .BrowserNewContextOptions ContextOptions(.TestContext testContext) { }
[.Before(., "", 0)]
Expand All @@ -33,6 +34,7 @@ namespace
public class PageTest : .ContextTest
{
public PageTest() { }
public PageTest(.BrowserTypeLaunchOptions options) { }
public .IPage Page { get; }
[.Before(., "", 0)]
public . PageSetup() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace
public class ContextTest : .BrowserTest
{
public ContextTest() { }
public ContextTest(.BrowserTypeLaunchOptions options) { }
public .IBrowserContext Context { get; }
public virtual .BrowserNewContextOptions ContextOptions(.TestContext testContext) { }
[.Before(., "", 0)]
Expand All @@ -33,6 +34,7 @@ namespace
public class PageTest : .ContextTest
{
public PageTest() { }
public PageTest(.BrowserTypeLaunchOptions options) { }
public .IPage Page { get; }
[.Before(., "", 0)]
public . PageSetup() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace
public class ContextTest : .BrowserTest
{
public ContextTest() { }
public ContextTest(.BrowserTypeLaunchOptions options) { }
public .IBrowserContext Context { get; }
public virtual .BrowserNewContextOptions ContextOptions(.TestContext testContext) { }
[.Before(., "", 0)]
Expand All @@ -33,6 +34,7 @@ namespace
public class PageTest : .ContextTest
{
public PageTest() { }
public PageTest(.BrowserTypeLaunchOptions options) { }
public .IPage Page { get; }
[.Before(., "", 0)]
public . PageSetup() { }
Expand Down
Loading