Skip to content

Commit dc502b6

Browse files
committed
[dotnet] start a BiDi session if webSocketUrl is set
1 parent 5bcd3e9 commit dc502b6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

dotnet/src/webdriver/WebDriver.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using System.Collections.ObjectModel;
2626
using System.Globalization;
2727
using System.Threading.Tasks;
28+
using WebDriverBiDi;
2829

2930
namespace OpenQA.Selenium
3031
{
@@ -46,6 +47,7 @@ public class WebDriver : IWebDriver, ISearchContext, IJavaScriptExecutor, IFinds
4647
private SessionId sessionId;
4748
private String authenticatorId;
4849
private List<string> registeredCommands = new List<string>();
50+
private BiDiDriver biDiDriver;
4951

5052
/// <summary>
5153
/// Initializes a new instance of the <see cref="WebDriver"/> class.
@@ -189,6 +191,14 @@ public SessionId SessionId
189191
get { return this.sessionId; }
190192
}
191193

194+
/// <summary>
195+
/// Gets the <see cref="BiDiDriver"/> for the current session of this driver.
196+
/// </summary>
197+
internal BiDiDriver BiDiDriver
198+
{
199+
get { return this.biDiDriver; }
200+
}
201+
192202
/// <summary>
193203
/// Gets or sets the <see cref="IFileDetector"/> responsible for detecting
194204
/// sequences of keystrokes representing file paths and names.
@@ -654,6 +664,13 @@ protected void StartSession(ICapabilities capabilities)
654664
ReturnedCapabilities returnedCapabilities = new ReturnedCapabilities(rawCapabilities);
655665
this.capabilities = returnedCapabilities;
656666
this.sessionId = new SessionId(response.SessionId);
667+
668+
if (!string.IsNullOrEmpty((string)this.capabilities.GetCapability("webSocketUrl")))
669+
{
670+
this.biDiDriver = new BiDiDriver(DefaultCommandTimeout);
671+
string webSocketUrl = this.capabilities.GetCapability("webSocketUrl").ToString();
672+
Task.Run(() => this.biDiDriver.StartAsync(webSocketUrl)).GetAwaiter().GetResult();
673+
}
657674
}
658675

659676
/// <summary>

0 commit comments

Comments
 (0)