AsyncChromeDriver 0.5.8

dotnet add package AsyncChromeDriver --version 0.5.8                
NuGet\Install-Package AsyncChromeDriver -Version 0.5.8                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AsyncChromeDriver" Version="0.5.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AsyncChromeDriver --version 0.5.8                
#r "nuget: AsyncChromeDriver, 0.5.8"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AsyncChromeDriver as a Cake Addin
#addin nuget:?package=AsyncChromeDriver&version=0.5.8

// Install AsyncChromeDriver as a Cake Tool
#tool nuget:?package=AsyncChromeDriver&version=0.5.8                

AsyncChromeDriver

Async .Net Chrome WebDriver and Chrome DevTools in one library.

It connects directly to Chrome DevTools and is async from this connection. No need in chromedriver.

AsyncChromeDriver implements IAsyncWebBrowserClient and can be used as AsyncWebDriver.

It also has DevTools property and you can easily use all power of Chrome DevTools from your .Net app. We use modified version from BaristaLabs/chrome-dev-tools-generator

Look video of BrowsersDevToolsExample: https://youtu.be/dNMuoeDmEME
Join the chat at https://gitter.im/AsyncWebDriver/Lobby

Usage

Install AsyncChromeDriver via NuGet

Targets Standard 2.0 and .NET Framework 4.6.2
If you want to include AsyncChromeDriver in your project, you can install it directly from NuGet

PM> Install-Package AsyncChromeDriver
> dotnet add package AsyncChromeDriver 
Write code example
     var asyncChromeDriver = new AsyncChromeDriver();
     var webDriver = new WebDriver(asyncChromeDriver);
     await webDriver.Options().Timeouts.SetImplicitWait(TimeSpan.FromSeconds(3));
     await webDriver.GoToUrl("https://www.google.com/");
     var query = await webDriver.FindElementByName("q");
     
     //await query.SendKeys("ToCSharp");
     var rnd = new Random();
     foreach (var v in "ToCSharp".ToList())
     {
        await Task.Delay(500 + rnd.Next(500));
        await query.SendKeys(v.ToString());
      }
      await Task.Delay(500);
      await query.SendKeys(Keys.Enter);
      var allCookies = await asyncChromeDriver.DevTools.Network.GetAllCookies();

      var screenshot = await webDriver.GetScreenshot();
      using (MemoryStream imageStream = new MemoryStream(screenshot.AsByteArray))
      {
        System.Drawing.Image screenshotImage = System.Drawing.Image.FromStream(imageStream);
        screenshotImage.Save(GetFilePathToSaveScreenshot(), System.Drawing.Imaging.ImageFormat.Png);
      }

Using DevTools

Protocol r982423 on Mar 18, 2022 (Chrome 99). https://github.com/ChromeDevTools/devtools-protocol/tree/master/json

    asyncChromeDriver = new AsyncChromeDriver();
    await asyncChromeDriver.CheckConnected();
    await asyncChromeDriver.DevTools.Page.Enable();
    asyncChromeDriver.DevTools.Page.SubscribeToLoadEventFiredEvent(async (e2) =>
    {
        var screenshot = await asyncChromeDriver.DevTools.Page.CaptureScreenshot();
        SaveScreenshot(screenshot.Data);
    });
    //await asyncChromeDriver.GoToUrl("https://www.google.com/");
    await asyncChromeDriver.DevTools.Page.Navigate(new ChromeDevTools.Page.NavigateCommand
    {
        Url = "https://www.google.com/"
    });
Headless Chrome
     var asyncChromeDriver = new AsyncChromeDriver(new ChromeDriverConfig().SetHeadless().SetWindowSize(width, height));
     var webDriver = new WebDriver(asyncChromeDriver);
     await webDriver.GoToUrl("https://www.google.com/");
     await Task.Delay(500);
     var screenshot = await webDriver.GetScreenshot();
     using (MemoryStream imageStream = new MemoryStream(screenshot.AsByteArray))
     {
        System.Drawing.Image screenshotImage = System.Drawing.Image.FromStream(imageStream);
        screenshotImage.Save(GetFilePathToSaveScreenshot(), System.Drawing.Imaging.ImageFormat.Png);
     }
     await webDriver.Close();
Chrome native Developer Tools

This feature is out of date. And you may further use it. But it opens unnecessary WebSocket server (we need remove this). Someday I do it if you ask.
https://developers.google.com/web/updates/2017/10/devtools-release-notes#multi-client
Look BrowsersDevToolsExample. It's interesting, you can open Developer tools for opened Developer tools.

   asyncChromeDriver = new AsyncChromeDriver(
        new ChromeDriverConfig().SetDoOpenBrowserDevTools());
   webDriver = new WebDriver(asyncChromeDriver);
   await asyncChromeDriver.Connect();
Examples

Look at AsyncChromeDriverExample.

Tests

Tests ported to async/await from selenium project In AsyncChromeDriver.Tests. Before run, start HtmlForTests (Start Without Debugging)
Or
Unit Tests from Selenuim run through SeleniumAdapterSyncWebDriverAsyncWebDriverAsyncChromeDriver

Implemented

Unit tests results for AsyncChromeDriver

In WebDriver part mostly implemented: Navigation, WebElements, Mouse, Keyboard, Clicks, ExecutingJavascript, TakesScreenshot.
Medium realized: Frame switching,
Poorly implemented: ExecutingAsyncJavascript
Not implemeted: Stale elements, Cookies, WindowSwitching, storages

It was ported from ChromeDriver not directly, partially.

Contribute!

If you see NotImplementedException, means you need functionality, which is not implemented yet.

Write issue or to Join the chat at https://gitter.im/AsyncWebDriver/Lobby. I implemented what I myself use at first.

Feel free to submit pull requests.

Please ⭐ star the project if you like it.

Thanks to

TODO

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on AsyncChromeDriver:

Package Downloads
AsyncOperaDriver

Opera WebDriver and Opera DevTools through a single connection

AsyncChromeDriver.SeleniumAdapter

Adapter to run Selenium tests through AsyncChromeDriver

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.5.8 2,166 3/27/2022
0.5.7 562 3/27/2022
0.5.6 2,212 1/26/2020
0.5.5 1,846 5/6/2019
0.5.4 1,130 1/30/2019
0.5.3 1,026 12/10/2018
0.5.2 1,141 12/8/2018
0.4.7 977 11/21/2018
0.4.6 1,049 11/4/2018
0.4.5 1,355 6/2/2018
0.4.4 1,252 4/19/2018
0.4.3 1,236 3/7/2018
0.4.2 1,232 3/3/2018
0.4.1 1,301 3/3/2018
0.3.15 1,438 10/22/2017
0.3.14 2,668 10/21/2017
0.3.12 1,226 10/18/2017
0.3.11 1,213 10/18/2017
0.3.10 1,419 10/18/2017
0.3.9 1,231 10/18/2017
0.3.8 1,442 10/13/2017
0.3.7 1,451 10/13/2017
0.3.6 1,257 10/12/2017
0.3.5 1,200 10/11/2017
0.3.4 1,418 10/10/2017
0.3.3 1,545 10/9/2017
0.3.2 1,731 10/9/2017
0.3.1 1,211 10/6/2017
0.2.10 1,229 10/5/2017
0.2.9 1,358 10/2/2017
0.2.8 2,229 10/1/2017
0.2.7 1,428 9/28/2017
0.2.6 1,591 9/25/2017
0.2.5 1,223 9/23/2017
0.2.4 1,230 9/21/2017
0.2.3 1,284 9/20/2017
0.2.2 1,247 9/20/2017
0.2.1 1,447 9/19/2017
0.1.13 1,276 9/5/2017
0.1.12 1,256 9/4/2017
0.1.11 1,249 9/2/2017
0.1.10 1,648 8/26/2017
0.1.9 1,247 8/25/2017
0.1.8 1,257 8/24/2017
0.1.7 1,283 8/23/2017
0.1.6 1,321 8/23/2017
0.1.5 1,417 8/16/2017
0.1.4 1,466 8/16/2017
0.1.3 1,241 8/16/2017
0.1.2 1,243 8/8/2017
0.1.1 1,142 8/2/2017

Protocol r982423 on Mar 18, 2022 (Chrome 99)