AsyncChromeDriver 0.5.8
dotnet add package AsyncChromeDriver --version 0.5.8
NuGet\Install-Package AsyncChromeDriver -Version 0.5.8
<PackageReference Include="AsyncChromeDriver" Version="0.5.8" />
paket add AsyncChromeDriver --version 0.5.8
#r "nuget: AsyncChromeDriver, 0.5.8"
// 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
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 SeleniumAdapter → SyncWebDriver → AsyncWebDriver → AsyncChromeDriver
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 . 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 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. |
-
.NETFramework 4.6.2
- AsyncWebDriver (>= 1.4.6)
- Newtonsoft.Json (>= 13.0.1)
- Zu.ChromeDevToolsClient (>= 0.5.6)
-
.NETStandard 2.0
- AsyncWebDriver (>= 1.4.6)
- Newtonsoft.Json (>= 13.0.1)
- Zu.ChromeDevToolsClient (>= 0.5.6)
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,165 | 3/27/2022 |
0.5.7 | 561 | 3/27/2022 |
0.5.6 | 2,209 | 1/26/2020 |
0.5.5 | 1,845 | 5/6/2019 |
0.5.4 | 1,129 | 1/30/2019 |
0.5.3 | 1,025 | 12/10/2018 |
0.5.2 | 1,140 | 12/8/2018 |
0.4.7 | 976 | 11/21/2018 |
0.4.6 | 1,048 | 11/4/2018 |
0.4.5 | 1,354 | 6/2/2018 |
0.4.4 | 1,251 | 4/19/2018 |
0.4.3 | 1,235 | 3/7/2018 |
0.4.2 | 1,231 | 3/3/2018 |
0.4.1 | 1,300 | 3/3/2018 |
0.3.15 | 1,437 | 10/22/2017 |
0.3.14 | 2,666 | 10/21/2017 |
0.3.12 | 1,225 | 10/18/2017 |
0.3.11 | 1,212 | 10/18/2017 |
0.3.10 | 1,418 | 10/18/2017 |
0.3.9 | 1,230 | 10/18/2017 |
0.3.8 | 1,441 | 10/13/2017 |
0.3.7 | 1,450 | 10/13/2017 |
0.3.6 | 1,256 | 10/12/2017 |
0.3.5 | 1,199 | 10/11/2017 |
0.3.4 | 1,417 | 10/10/2017 |
0.3.3 | 1,544 | 10/9/2017 |
0.3.2 | 1,730 | 10/9/2017 |
0.3.1 | 1,210 | 10/6/2017 |
0.2.10 | 1,228 | 10/5/2017 |
0.2.9 | 1,357 | 10/2/2017 |
0.2.8 | 2,228 | 10/1/2017 |
0.2.7 | 1,427 | 9/28/2017 |
0.2.6 | 1,590 | 9/25/2017 |
0.2.5 | 1,222 | 9/23/2017 |
0.2.4 | 1,229 | 9/21/2017 |
0.2.3 | 1,283 | 9/20/2017 |
0.2.2 | 1,246 | 9/20/2017 |
0.2.1 | 1,446 | 9/19/2017 |
0.1.13 | 1,275 | 9/5/2017 |
0.1.12 | 1,255 | 9/4/2017 |
0.1.11 | 1,248 | 9/2/2017 |
0.1.10 | 1,647 | 8/26/2017 |
0.1.9 | 1,246 | 8/25/2017 |
0.1.8 | 1,256 | 8/24/2017 |
0.1.7 | 1,282 | 8/23/2017 |
0.1.6 | 1,320 | 8/23/2017 |
0.1.5 | 1,416 | 8/16/2017 |
0.1.4 | 1,465 | 8/16/2017 |
0.1.3 | 1,240 | 8/16/2017 |
0.1.2 | 1,242 | 8/8/2017 |
0.1.1 | 1,141 | 8/2/2017 |
Protocol r982423 on Mar 18, 2022 (Chrome 99)