|
1 | | -using Microsoft.Playwright; |
2 | | -using Xunit; |
3 | | - |
4 | | -namespace OrchardCoreContrib.Testing.UI; |
| 1 | +namespace OrchardCoreContrib.Testing.UI; |
5 | 2 |
|
6 | 3 | /// <summary> |
7 | 4 | /// Represents a UI testing class. |
8 | 5 | /// </summary> |
9 | 6 | /// <param name="browserType">The browser type that will be used during the test. Defaults to <see cref="BrowserType.Edge"/>.</param> |
10 | 7 | /// <param name="headless">Whether the browser runs in headless mode or not. Defaults to <c>true</c>.</param> |
11 | | -public class UITest(BrowserType browserType = BrowserType.Edge, bool headless = true) : IAsyncLifetime |
12 | | -{ |
13 | | - private IPlaywright _playwright; |
14 | | - |
15 | | - /// <summary> |
16 | | - /// Gets the browser instance to be used during the test. |
17 | | - /// </summary> |
18 | | - public IBrowser Browser { get; private set; } |
19 | | - |
20 | | - public UITestOptions Options { get; private set; } |
21 | | - |
22 | | - /// <inheritdoc/> |
23 | | - public async Task InitializeAsync() |
| 8 | +/// <param name="delay">The amount of time to wait between execute two actions. Defaults to <c>0</c>.</param> |
| 9 | +public class UITest(BrowserType browserType = BrowserType.Edge, bool headless = true, int delay = 0) |
| 10 | + : UITestBase(new UITestOptions |
24 | 11 | { |
25 | | - Options = new UITestOptions |
26 | | - { |
27 | | - BrowserType = browserType, |
28 | | - Headless = headless |
29 | | - }; |
30 | | - |
31 | | - _playwright = await Playwright.CreateAsync(); |
32 | | - |
33 | | - Browser = await BrowserFactory.CreateAsync(_playwright, Options); |
34 | | - } |
35 | | - |
36 | | - /// <inheritdoc/> |
37 | | - public async Task DisposeAsync() |
38 | | - { |
39 | | - _playwright.Dispose(); |
40 | | - |
41 | | - await Task.CompletedTask; |
42 | | - } |
| 12 | + BrowserType = browserType, |
| 13 | + Headless = headless, |
| 14 | + Delay = delay |
| 15 | + }) |
| 16 | +{ |
43 | 17 | } |
0 commit comments