AsyncChromeDriver 0.5.8

.NET Standard 2.0 .NET Framework 4.6.2
Install-Package AsyncChromeDriver -Version 0.5.8
dotnet add package AsyncChromeDriver --version 0.5.8
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AsyncChromeDriver, 0.5.8"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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 Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
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 126 3/27/2022
0.5.7 52 3/27/2022
0.5.6 1,860 1/26/2020
0.5.5 1,334 5/6/2019
0.5.4 855 1/30/2019
0.5.3 756 12/10/2018
0.5.2 870 12/8/2018
0.4.7 712 11/21/2018
0.4.6 757 11/4/2018
0.4.5 1,037 6/2/2018
0.4.4 909 4/19/2018
0.4.3 915 3/7/2018
0.4.2 909 3/3/2018
0.4.1 959 3/3/2018
0.3.15 1,070 10/22/2017
0.3.14 1,669 10/21/2017
0.3.12 869 10/18/2017
0.3.11 882 10/18/2017
0.3.10 975 10/18/2017
0.3.9 891 10/18/2017
0.3.8 981 10/13/2017
0.3.7 996 10/13/2017
0.3.6 915 10/12/2017
0.3.5 872 10/11/2017
0.3.4 964 10/10/2017
0.3.3 1,082 10/9/2017
0.3.2 1,174 10/9/2017
0.3.1 883 10/6/2017
0.2.10 892 10/5/2017
0.2.9 966 10/2/2017
0.2.8 1,385 10/1/2017
0.2.7 973 9/28/2017
0.2.6 1,046 9/25/2017
0.2.5 880 9/23/2017
0.2.4 900 9/21/2017
0.2.3 945 9/20/2017
0.2.2 890 9/20/2017
0.2.1 993 9/19/2017
0.1.13 933 9/5/2017
0.1.12 918 9/4/2017
0.1.11 916 9/2/2017
0.1.10 1,131 8/26/2017
0.1.9 915 8/25/2017
0.1.8 913 8/24/2017
0.1.7 922 8/23/2017
0.1.6 980 8/23/2017
0.1.5 1,003 8/16/2017
0.1.4 1,043 8/16/2017
0.1.3 934 8/16/2017
0.1.2 925 8/8/2017
0.1.1 860 8/2/2017

Protocol r982423 on Mar 18, 2022 (Chrome 99)