Skip to content

Commit

Permalink
Rename DriverInitEvent to WebDriverInitCompletedEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
YevgeniyShunevych committed Jan 16, 2025
1 parent d134ef0 commit 931de84
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/Atata/Events/DriverInitEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Atata;

/// <summary>
/// Represents an event that occurs when <see cref="AtataContext"/> driver is initializing.
/// </summary>
[Obsolete("Use WebDriverInitCompletedEvent instead.")] // Obsolete since v4.0.0.
public sealed class DriverInitEvent
{
internal DriverInitEvent(IWebDriver driver) =>
Expand Down
17 changes: 17 additions & 0 deletions src/Atata/WebDriver/Events/WebDriverInitCompletedEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#nullable enable

namespace Atata;

/// <summary>
/// Represents an event that occurs when <see cref="WebDriverSession.Driver"/> is initialized.
/// </summary>
public sealed class WebDriverInitCompletedEvent
{
internal WebDriverInitCompletedEvent(IWebDriver driver) =>
Driver = driver;

/// <summary>
/// Gets the driver.
/// </summary>
public IWebDriver Driver { get; }
}
4 changes: 4 additions & 0 deletions src/Atata/WebDriver/WebDriverSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ private void InitDriver() =>
RetrySettings.Timeout = ElementFindTimeout;
RetrySettings.Interval = ElementFindRetryInterval;

#pragma warning disable CS0618 // Type or member is obsolete
EventBus.Publish(new DriverInitEvent(_driver));
#pragma warning restore CS0618 // Type or member is obsolete

EventBus.Publish(new WebDriverInitCompletedEvent(_driver));
});

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Atata/WebDriver/WebDriverSessionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ protected override void ValidateConfiguration()
}
}

private static void EnableBrowserLogMonitoringOnDriverInitEvent(
private static void EnableBrowserLogMonitoringOnWebDriverInitCompletedEvent(
IWebDriver driver,
WebDriverSession session,
IEnumerable<IBrowserLogHandler> browserLogHandlers)
Expand Down Expand Up @@ -469,8 +469,8 @@ private void InitBrowserLogMonitoring(WebDriverSession session)
if (BrowserLogs.MinLevelOfWarning is not null)
browserLogHandlers.Add(new WarningBrowserLogHandler(session, BrowserLogs.MinLevelOfWarning.Value));

session.EventBus.Subscribe<DriverInitEvent>(
(e, _) => EnableBrowserLogMonitoringOnDriverInitEvent(e.Driver, session, browserLogHandlers));
session.EventBus.Subscribe<WebDriverInitCompletedEvent>(
(e, _) => EnableBrowserLogMonitoringOnWebDriverInitCompletedEvent(e.Driver, session, browserLogHandlers));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
public sealed class WebDriverSessionEventsTests : WebDriverSessionTestSuiteBase
{
[Test]
public void DriverInitEvent()
public void WebDriverInitCompletedEvent()
{
int executionsCount = 0;
IWebDriver driverOfEvent = null;

var builder = ConfigureAtataContextWithWebDriverSession(session =>
session.EventSubscriptions.Add<DriverInitEvent>((eventData, _) =>
session.EventSubscriptions.Add<WebDriverInitCompletedEvent>((eventData, _) =>
{
driverOfEvent = eventData.Driver;
executionsCount++;
Expand All @@ -21,13 +21,13 @@ public void DriverInitEvent()
}

[Test]
public void DriverInitEvent_WhenRestartDriver()
public void WebDriverInitCompletedEvent_WhenRestartDriver()
{
int executionsCount = 0;
IWebDriver initialDriver = null;

var builder = ConfigureAtataContextWithWebDriverSession(session =>
session.EventSubscriptions.Add<DriverInitEvent>(eventData =>
session.EventSubscriptions.Add<WebDriverInitCompletedEvent>(eventData =>
{
if (executionsCount == 0)
initialDriver = eventData.Driver;
Expand Down
2 changes: 1 addition & 1 deletion test/Atata.IntegrationTests/WebDriverSessionTestSuite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void SetUp()
if (PreservedDriver is not null)
session.UseDriver(PreservedDriver);

session.EventSubscriptions.Add<DriverInitEvent>(
session.EventSubscriptions.Add<WebDriverInitCompletedEvent>(
eventData => PreservedDriver ??= eventData.Driver);
}
});
Expand Down

0 comments on commit 931de84

Please sign in to comment.