- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.6k
 
[dotnet] BiDi implementation #14318
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
          
     Merged
      
      
    
  
     Merged
                    [dotnet] BiDi implementation #14318
Changes from all commits
      Commits
    
    
            Show all changes
          
          
            15 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      a4e72d0
              
                Migrate
              
              
                nvborisenko f5ea88c
              
                Use CLS compliant long instead of ulong
              
              
                nvborisenko ec12b47
              
                Merge branch 'trunk' into dotnet-bidi
              
              
                nvborisenko 8e2f547
              
                Use null instead of default for optional arguments
              
              
                nvborisenko 2e62e98
              
                Merge branch 'dotnet-bidi' of https://github.com/nvborisenko/selenium…
              
              
                nvborisenko 3ab0cf5
              
                Use internal logging in websockettransport
              
              
                nvborisenko a83cd1d
              
                Use internal logger in broker
              
              
                nvborisenko 0cc6df9
              
                Even with error log level
              
              
                nvborisenko 6ef2886
              
                Simplify AsBidirectionalContextAsync
              
              
                nvborisenko ac6f188
              
                Fix ConfigureAwait in network module
              
              
                nvborisenko 208acb9
              
                Hide direct network interception
              
              
                nvborisenko 4074189
              
                Rework public adding interception
              
              
                nvborisenko 61fcec0
              
                Simplify network interception
              
              
                nvborisenko de037db
              
                Don't end session when disposing bidi driver
              
              
                nvborisenko 6b70306
              
                Merge branch 'trunk' into dotnet-bidi
              
              
                nvborisenko File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using OpenQA.Selenium.BiDi.Communication; | ||
| using OpenQA.Selenium.BiDi.Communication.Transport; | ||
| 
     | 
||
| namespace OpenQA.Selenium.BiDi; | ||
| 
     | 
||
| public class BiDi : IAsyncDisposable | ||
| { | ||
| private readonly ITransport _transport; | ||
| private readonly Broker _broker; | ||
| 
     | 
||
| private readonly Lazy<Modules.Session.SessionModule> _sessionModule; | ||
| private readonly Lazy<Modules.BrowsingContext.BrowsingContextModule> _browsingContextModule; | ||
| private readonly Lazy<Modules.Browser.BrowserModule> _browserModule; | ||
| private readonly Lazy<Modules.Network.NetworkModule> _networkModule; | ||
| private readonly Lazy<Modules.Input.InputModule> _inputModule; | ||
| private readonly Lazy<Modules.Script.ScriptModule> _scriptModule; | ||
| private readonly Lazy<Modules.Log.LogModule> _logModule; | ||
| private readonly Lazy<Modules.Storage.StorageModule> _storageModule; | ||
| 
     | 
||
| internal BiDi(string url) | ||
| { | ||
| var uri = new Uri(url); | ||
| 
     | 
||
| _transport = new WebSocketTransport(new Uri(url)); | ||
| _broker = new Broker(this, _transport); | ||
| 
     | 
||
| _sessionModule = new Lazy<Modules.Session.SessionModule>(() => new Modules.Session.SessionModule(_broker)); | ||
| _browsingContextModule = new Lazy<Modules.BrowsingContext.BrowsingContextModule>(() => new Modules.BrowsingContext.BrowsingContextModule(_broker)); | ||
| _browserModule = new Lazy<Modules.Browser.BrowserModule>(() => new Modules.Browser.BrowserModule(_broker)); | ||
| _networkModule = new Lazy<Modules.Network.NetworkModule>(() => new Modules.Network.NetworkModule(_broker)); | ||
| _inputModule = new Lazy<Modules.Input.InputModule>(() => new Modules.Input.InputModule(_broker)); | ||
| _scriptModule = new Lazy<Modules.Script.ScriptModule>(() => new Modules.Script.ScriptModule(_broker)); | ||
| _logModule = new Lazy<Modules.Log.LogModule>(() => new Modules.Log.LogModule(_broker)); | ||
| _storageModule = new Lazy<Modules.Storage.StorageModule>(() => new Modules.Storage.StorageModule(_broker)); | ||
| } | ||
| 
     | 
||
| internal Modules.Session.SessionModule SessionModule => _sessionModule.Value; | ||
| internal Modules.BrowsingContext.BrowsingContextModule BrowsingContextModule => _browsingContextModule.Value; | ||
| public Modules.Browser.BrowserModule Browser => _browserModule.Value; | ||
| public Modules.Network.NetworkModule Network => _networkModule.Value; | ||
| internal Modules.Input.InputModule InputModule => _inputModule.Value; | ||
| internal Modules.Script.ScriptModule ScriptModule => _scriptModule.Value; | ||
| public Modules.Log.LogModule Log => _logModule.Value; | ||
| public Modules.Storage.StorageModule Storage => _storageModule.Value; | ||
| 
     | 
||
| public Task<Modules.Session.StatusResult> StatusAsync() | ||
| { | ||
| return SessionModule.StatusAsync(); | ||
| } | ||
| 
     | 
||
| public static async Task<BiDi> ConnectAsync(string url) | ||
| { | ||
| var bidi = new BiDi(url); | ||
| 
     | 
||
| await bidi._broker.ConnectAsync(default).ConfigureAwait(false); | ||
| 
     | 
||
| return bidi; | ||
| } | ||
| 
     | 
||
| public Task<Modules.BrowsingContext.BrowsingContext> CreateBrowsingContextAsync(Modules.BrowsingContext.BrowsingContextType type, Modules.BrowsingContext.CreateOptions? options = null) | ||
| { | ||
| return BrowsingContextModule.CreateAsync(type, options); | ||
| } | ||
| 
     | 
||
| public Task<IReadOnlyList<Modules.BrowsingContext.BrowsingContextInfo>> GetBrowsingContextTreeAsync(Modules.BrowsingContext.GetTreeOptions? options = null) | ||
| { | ||
| return BrowsingContextModule.GetTreeAsync(options); | ||
| } | ||
| 
     | 
||
| public Task EndAsync(Modules.Session.EndOptions? options = null) | ||
| { | ||
| return SessionModule.EndAsync(options); | ||
| } | ||
| 
     | 
||
| public async ValueTask DisposeAsync() | ||
| { | ||
| await _broker.DisposeAsync().ConfigureAwait(false); | ||
| 
     | 
||
| _transport?.Dispose(); | ||
| } | ||
| 
     | 
||
| public Task<Subscription> OnBrowsingContextCreatedAsync(Func<Modules.BrowsingContext.BrowsingContextInfo, Task> handler, BrowsingContextsSubscriptionOptions? options = null) | ||
| { | ||
| return BrowsingContextModule.OnContextCreatedAsync(handler, options); | ||
| } | ||
| 
     | 
||
| public Task<Subscription> OnBrowsingContextCreatedAsync(Action<Modules.BrowsingContext.BrowsingContextInfo> handler, BrowsingContextsSubscriptionOptions? options = null) | ||
| { | ||
| return BrowsingContextModule.OnContextCreatedAsync(handler, options); | ||
| } | ||
| 
     | 
||
| public Task<Subscription> OnBrowsingContextDestroyedAsync(Func<Modules.BrowsingContext.BrowsingContextInfo, Task> handler, BrowsingContextsSubscriptionOptions? options = null) | ||
| { | ||
| return BrowsingContextModule.OnContextDestroyedAsync(handler, options); | ||
| } | ||
| 
     | 
||
| public Task<Subscription> OnBrowsingContextDestroyedAsync(Action<Modules.BrowsingContext.BrowsingContextInfo> handler, BrowsingContextsSubscriptionOptions? options = null) | ||
| { | ||
| return BrowsingContextModule.OnContextDestroyedAsync(handler, options); | ||
| } | ||
| 
     | 
||
| public Task<Subscription> OnUserPromptOpenedAsync(Func<Modules.BrowsingContext.UserPromptOpenedEventArgs, Task> handler, BrowsingContextsSubscriptionOptions? options = null) | ||
| { | ||
| return BrowsingContextModule.OnUserPromptOpenedAsync(handler, options); | ||
| } | ||
| 
     | 
||
| public Task<Subscription> OnUserPromptOpenedAsync(Action<Modules.BrowsingContext.UserPromptOpenedEventArgs> handler, BrowsingContextsSubscriptionOptions? options = null) | ||
| { | ||
| return BrowsingContextModule.OnUserPromptOpenedAsync(handler, options); | ||
| } | ||
| 
     | 
||
| public Task<Subscription> OnUserPromptClosedAsync(Func<Modules.BrowsingContext.UserPromptClosedEventArgs, Task> handler, BrowsingContextsSubscriptionOptions? options = null) | ||
| { | ||
| return BrowsingContextModule.OnUserPromptClosedAsync(handler, options); | ||
| } | ||
| 
     | 
||
| public Task<Subscription> OnUserPromptClosedAsync(Action<Modules.BrowsingContext.UserPromptClosedEventArgs> handler, BrowsingContextsSubscriptionOptions? options = null) | ||
| { | ||
| return BrowsingContextModule.OnUserPromptClosedAsync(handler, options); | ||
| } | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System; | ||
| 
     | 
||
| namespace OpenQA.Selenium.BiDi; | ||
| 
     | 
||
| public class BiDiException : Exception | ||
| { | ||
| public BiDiException(string message) : base(message) | ||
| { | ||
| } | ||
| } | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.