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,204 3/27/2022
0.5.7 579 3/27/2022
0.5.6 2,223 1/26/2020
0.5.5 1,865 5/6/2019
0.5.4 1,142 1/30/2019
0.5.3 1,038 12/10/2018
0.5.2 1,154 12/8/2018
0.4.7 990 11/21/2018
0.4.6 1,062 11/4/2018
0.4.5 1,370 6/2/2018
0.4.4 1,269 4/19/2018
0.4.3 1,253 3/7/2018
0.4.2 1,247 3/3/2018
0.4.1 1,316 3/3/2018
0.3.15 1,453 10/22/2017
0.3.14 2,712 10/21/2017
0.3.12 1,241 10/18/2017
0.3.11 1,228 10/18/2017
0.3.10 1,434 10/18/2017
0.3.9 1,248 10/18/2017
0.3.8 1,457 10/13/2017
0.3.7 1,466 10/13/2017
0.3.6 1,272 10/12/2017
0.3.5 1,215 10/11/2017
0.3.4 1,433 10/10/2017
0.3.3 1,560 10/9/2017
0.3.2 1,746 10/9/2017
0.3.1 1,226 10/6/2017
0.2.10 1,244 10/5/2017
0.2.9 1,375 10/2/2017
0.2.8 2,244 10/1/2017
0.2.7 1,443 9/28/2017
0.2.6 1,606 9/25/2017
0.2.5 1,238 9/23/2017
0.2.4 1,244 9/21/2017
0.2.3 1,298 9/20/2017
0.2.2 1,261 9/20/2017
0.2.1 1,463 9/19/2017
0.1.13 1,291 9/5/2017
0.1.12 1,271 9/4/2017
0.1.11 1,263 9/2/2017
0.1.10 1,662 8/26/2017
0.1.9 1,262 8/25/2017
0.1.8 1,273 8/24/2017
0.1.7 1,299 8/23/2017
0.1.6 1,336 8/23/2017
0.1.5 1,433 8/16/2017
0.1.4 1,481 8/16/2017
0.1.3 1,256 8/16/2017
0.1.2 1,258 8/8/2017
0.1.1 1,157 8/2/2017

Protocol r982423 on Mar 18, 2022 (Chrome 99)