-
Notifications
You must be signed in to change notification settings - Fork 4
feature/RM-9546 update selenium to 4.35.0 #1366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
5be7773
79d4a3b
eb30ee8
0689e51
731a349
800b708
9940570
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,7 @@ | |
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using Coypu; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.BiDi; | ||
using OpenQA.Selenium.BiDi.Modules.BrowsingContext; | ||
|
||
namespace Remotion.Web.Development.WebTesting.BrowserSession; | ||
|
||
|
@@ -19,24 +16,20 @@ namespace Remotion.Web.Development.WebTesting.BrowserSession; | |
/// </remarks> | ||
public class BiDiBrowserLogProvider : IBrowserLogProvider, IDisposable | ||
{ | ||
private readonly IDriver _driver; | ||
|
||
private readonly ConcurrentQueue<BrowserLogEntry> _logEntries = new(); | ||
private readonly Subscription _eventSubscription; | ||
private readonly TimeSpan _bidiTimeout = TimeSpan.FromSeconds(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is duplicated with BrowserSessionBase. should we move this into the IBrowserSession (or IBidiConnectionManager) interface to avoid duplication? |
||
|
||
public BiDiBrowserLogProvider (IDriver driver) | ||
public BiDiBrowserLogProvider (IBrowserSession browserSession) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. design question: should we have an interface smaller than IBrowserSession (IBidiConnectionService) or some such? |
||
{ | ||
ArgumentNullException.ThrowIfNull(driver); | ||
|
||
_driver = driver; | ||
|
||
var bidi = ((IWebDriver)driver.Native).AsBiDiAsync().GetAwaiter().GetResult(); | ||
_eventSubscription = bidi.Log.OnEntryAddedAsync(entry => _logEntries.Enqueue(new BrowserLogEntry(entry))).GetAwaiter().GetResult(); | ||
ArgumentNullException.ThrowIfNull(browserSession); | ||
|
||
// Accept all user prompts as they come up - IWebTestHelper.AcceptPossibleModalDialog() does not work with BiDi | ||
// because the WebTest-Thread is not continued when a user prompt is shown. | ||
bidi.BrowsingContext.OnUserPromptOpenedAsync(args => args.BiDi.BrowsingContext.HandleUserPromptAsync(args.Context, new HandleUserPromptOptions { Accept = true })).Wait(); | ||
} | ||
browserSession.OpenBidiConnection(); | ||
_eventSubscription = browserSession.BiDiConnection.Log.OnEntryAddedAsync(entry => _logEntries.Enqueue(new BrowserLogEntry(entry)), new SubscriptionOptions | ||
{ | ||
Timeout = _bidiTimeout | ||
}).GetAwaiter().GetResult(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IReadOnlyCollection<BrowserLogEntry> GetBrowserLogs () | ||
|
@@ -52,10 +45,13 @@ public void ResetBrowserLogs () | |
|
||
public void Dispose () | ||
{ | ||
_eventSubscription.DisposeAsync().AsTask().GetAwaiter().GetResult(); | ||
|
||
var driver = (IWebDriver)_driver.Native; | ||
var biDi = driver.AsBiDiAsync().GetAwaiter().GetResult(); | ||
biDi.DisposeAsync().GetAwaiter().GetResult(); | ||
try | ||
{ | ||
_eventSubscription.DisposeAsync().AsTask().GetAwaiter().GetResult(); | ||
} | ||
catch (Exception) | ||
{ | ||
//ignored | ||
dkudernatsch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
dkudernatsch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ | |
using Coypu; | ||
using JetBrains.Annotations; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.BiDi; | ||
using OpenQA.Selenium.BiDi.BrowsingContext; | ||
using Remotion.Web.Development.WebTesting.Utilities; | ||
using Remotion.Web.Development.WebTesting.WebDriver.Configuration; | ||
|
||
|
@@ -43,15 +45,18 @@ public static void ApplyCommonWebTestFeatureDefaults ( | |
} | ||
|
||
private readonly TimeSpan _browserProcessesShutdownTime = TimeSpan.FromSeconds(60); | ||
private readonly TimeSpan _bidiTimeout = TimeSpan.FromSeconds(1); | ||
|
||
private readonly T _browserConfiguration; | ||
private readonly Coypu.BrowserSession _value; | ||
private readonly int _driverProcessID; | ||
private readonly bool _headless; | ||
private bool _isDisposed; | ||
|
||
private readonly WebTestFeatureCollection _features; | ||
|
||
private BiDi? _bidiConnection; | ||
private Subscription? _promptSubscription; | ||
private bool _isDisposed; | ||
|
||
protected BrowserSessionBase ( | ||
[NotNull] Coypu.BrowserSession value, | ||
[NotNull] T browserConfiguration, | ||
|
@@ -87,9 +92,26 @@ protected T BrowserConfiguration | |
get { return _browserConfiguration; } | ||
} | ||
|
||
public void AcceptModalDialog (Options? options = null) | ||
public BiDi BiDiConnection => _bidiConnection | ||
?? throw new InvalidOperationException("Call 'OpenBidiConnection' before accessing 'BiDiConnection'."); | ||
|
||
[System.Diagnostics.CodeAnalysis.MemberNotNull(nameof(_bidiConnection))] | ||
public void OpenBidiConnection () | ||
{ | ||
_value.AcceptModalDialog(options); | ||
if (_bidiConnection != null) | ||
return; | ||
|
||
_bidiConnection = ((OpenQA.Selenium.WebDriver)Driver.Native).AsBiDiAsync().GetAwaiter().GetResult(); | ||
|
||
// Accept all user prompts as they come up - IWebTestHelper.AcceptPossibleModalDialog() does not work with BiDi | ||
// because the WebTest-Thread is not continued when a user prompt is shown. | ||
_promptSubscription = _bidiConnection.BrowsingContext.OnUserPromptOpenedAsync(args => | ||
args.BiDi.BrowsingContext.HandleUserPromptAsync(args.Context, new HandleUserPromptOptions { Accept = true, Timeout = _bidiTimeout}).GetAwaiter().GetResult(), | ||
new BrowsingContextsSubscriptionOptions(new SubscriptionOptions | ||
{ | ||
Timeout = _bidiTimeout | ||
})) | ||
.GetAwaiter().GetResult(); | ||
Comment on lines
+106
to
+114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I remember a discussion about making this conditional based on there actually being a user propmt expected right now. Did we nix this completely or just deferr? if it's deferred we should create a jira ticket and refernece the issue number here with a short explaintion that this will get aligned with the correct handling semantics in a later iteration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. scope based handling of Userpromt in another task, add comment with ticket |
||
} | ||
|
||
public IDriver Driver | ||
|
@@ -137,9 +159,27 @@ public virtual void Dispose () | |
return; | ||
|
||
_isDisposed = true; | ||
|
||
_features.Dispose(); | ||
|
||
try | ||
{ | ||
_promptSubscription?.DisposeAsync().AsTask().GetAwaiter().GetResult(); | ||
} | ||
catch (Exception) | ||
{ | ||
//ignored | ||
} | ||
|
||
try | ||
{ | ||
_bidiConnection?.DisposeAsync().AsTask().GetAwaiter().GetResult(); | ||
} | ||
catch (Exception) | ||
{ | ||
//ignored | ||
} | ||
dkudernatsch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
// Get processes for driver and main browser, as well as the sub processes of the browser | ||
var driverProcess = FindDriverProcess(); | ||
var browserProcess = FindBrowserProcess(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the jira issue number where this will get fixed and a short explanation in the ignore about why it's ignored.