diff --git a/src/OrchardCoreContrib.Testing.UI/IUITest.cs b/src/OrchardCoreContrib.Testing.UI/IUITest.cs
new file mode 100644
index 0000000..990f653
--- /dev/null
+++ b/src/OrchardCoreContrib.Testing.UI/IUITest.cs
@@ -0,0 +1,19 @@
+using Xunit;
+
+namespace OrchardCoreContrib.Testing.UI;
+
+///
+/// Represents a contract for UI test.
+///
+public interface IUITest : IAsyncLifetime
+{
+ ///
+ /// Gets or sets the browser instance to be used during the test.
+ ///
+ public IBrowser Browser { get; set; }
+
+ ///
+ /// Gets the options used during the test.
+ ///
+ public UITestOptions Options { get; }
+}
diff --git a/src/OrchardCoreContrib.Testing.UI/UITest.cs b/src/OrchardCoreContrib.Testing.UI/UITest.cs
index e6cfe53..9e98153 100644
--- a/src/OrchardCoreContrib.Testing.UI/UITest.cs
+++ b/src/OrchardCoreContrib.Testing.UI/UITest.cs
@@ -1,43 +1,17 @@
-using Microsoft.Playwright;
-using Xunit;
-
-namespace OrchardCoreContrib.Testing.UI;
+namespace OrchardCoreContrib.Testing.UI;
///
/// Represents a UI testing class.
///
/// The browser type that will be used during the test. Defaults to .
/// Whether the browser runs in headless mode or not. Defaults to true.
-public class UITest(BrowserType browserType = BrowserType.Edge, bool headless = true) : IAsyncLifetime
-{
- private IPlaywright _playwright;
-
- ///
- /// Gets the browser instance to be used during the test.
- ///
- public IBrowser Browser { get; private set; }
-
- public UITestOptions Options { get; private set; }
-
- ///
- public async Task InitializeAsync()
+/// The amount of time to wait between execute two actions. Defaults to 0.
+public class UITest(BrowserType browserType = BrowserType.Edge, bool headless = true, int delay = 0)
+ : UITestBase(new UITestOptions
{
- Options = new UITestOptions
- {
- BrowserType = browserType,
- Headless = headless
- };
-
- _playwright = await Playwright.CreateAsync();
-
- Browser = await BrowserFactory.CreateAsync(_playwright, Options);
- }
-
- ///
- public async Task DisposeAsync()
- {
- _playwright.Dispose();
-
- await Task.CompletedTask;
- }
+ BrowserType = browserType,
+ Headless = headless,
+ Delay = delay
+ })
+{
}
diff --git a/src/OrchardCoreContrib.Testing.UI/UITestBase.cs b/src/OrchardCoreContrib.Testing.UI/UITestBase.cs
index 5bd552f..5271059 100644
--- a/src/OrchardCoreContrib.Testing.UI/UITestBase.cs
+++ b/src/OrchardCoreContrib.Testing.UI/UITestBase.cs
@@ -1,18 +1,34 @@
-using OrchardCoreContrib.Testing.UI.Infrastructure;
+using Microsoft.Playwright;
namespace OrchardCoreContrib.Testing.UI;
-///
-/// Represents a base class for UI testing.
-///
-/// The startup class that will be used as entry point.
-/// The .
-public abstract class UITestBase(WebApplicationFactoryFixture fixture) where TStartup : class
+public abstract class UITestBase(UITestOptions testOptions) : IUITest
{
+ private IPlaywright _playwright;
+
+ ///
+ /// Gets or sets the browser instance to be used during the test.
+ ///
+ public IBrowser Browser { get; set; }
+
///
- /// Gets the base URL used for the tested website.
+ /// Gets the options used during the test.
///
- public string BaseUrl => fixture.ServerAddress;
+ public UITestOptions Options => testOptions;
+
+ ///
+ public virtual async Task InitializeAsync()
+ {
+ _playwright = await Playwright.CreateAsync();
+
+ Browser = await BrowserFactory.CreateAsync(_playwright, Options);
+ }
+
+ ///
+ public virtual async Task DisposeAsync()
+ {
+ _playwright.Dispose();
- public UITestOptions Options { get; protected set; }
+ await Task.CompletedTask;
+ }
}
diff --git a/src/OrchardCoreContrib.Testing.UI/UITestBaseOfT.cs b/src/OrchardCoreContrib.Testing.UI/UITestBaseOfT.cs
new file mode 100644
index 0000000..b62826b
--- /dev/null
+++ b/src/OrchardCoreContrib.Testing.UI/UITestBaseOfT.cs
@@ -0,0 +1,17 @@
+using OrchardCoreContrib.Testing.UI.Infrastructure;
+
+namespace OrchardCoreContrib.Testing.UI;
+
+///
+/// Represents a base class for UI testing.
+///
+/// The startup class that will be used as entry point.
+/// The .
+public abstract class UITestBase(WebApplicationFactoryFixture fixture, UITestOptions testOptions)
+ : UITestBase(testOptions) where TStartup : class
+{
+ ///
+ /// Gets the base URL used for the tested website.
+ ///
+ public string BaseUrl => fixture.ServerAddress;
+}
diff --git a/src/OrchardCoreContrib.Testing.UI/UITestOfT.cs b/src/OrchardCoreContrib.Testing.UI/UITestOfT.cs
index 8f3efab..7bc998d 100644
--- a/src/OrchardCoreContrib.Testing.UI/UITestOfT.cs
+++ b/src/OrchardCoreContrib.Testing.UI/UITestOfT.cs
@@ -1,6 +1,4 @@
-using Microsoft.Playwright;
-using OrchardCoreContrib.Testing.UI.Infrastructure;
-using Xunit;
+using OrchardCoreContrib.Testing.UI.Infrastructure;
namespace OrchardCoreContrib.Testing.UI;
@@ -9,37 +7,14 @@ namespace OrchardCoreContrib.Testing.UI;
///
/// The browser type that will be used during the test. Defaults to .
/// Whether the browser runs in headless mode or not. Defaults to true.
+/// The amount of time to wait between execute two actions. Defaults to 0.
/// The startup class type that will be used as entry point.
-public class UITest(BrowserType browserType = BrowserType.Edge, bool headless = true) :
- UITestBase(new WebApplicationFactoryFixture()),
- IAsyncLifetime where TStartup : class
-{
- private IPlaywright _playwright;
-
- ///
- /// Gets the browser instance to be used during the test.
- ///
- public IBrowser Browser { get; private set; }
-
- ///
- public async Task InitializeAsync()
+public class UITest(BrowserType browserType = BrowserType.Edge, bool headless = true, int delay = 0) :
+ UITestBase(new WebApplicationFactoryFixture(), new UITestOptions
{
- Options = new UITestOptions
- {
- BrowserType = browserType,
- Headless = headless
- };
-
- _playwright = await Playwright.CreateAsync();
-
- Browser = await BrowserFactory.CreateAsync(_playwright, Options);
- }
-
- ///
- public async Task DisposeAsync()
- {
- _playwright.Dispose();
-
- await Task.CompletedTask;
- }
+ BrowserType = browserType,
+ Headless = headless,
+ Delay = delay
+ }), IUITest where TStartup : class
+{
}