2525using System . Collections . ObjectModel ;
2626using System . Globalization ;
2727using System . Threading . Tasks ;
28+ using WebDriverBiDi ;
2829
2930namespace 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