All Projects → microsoft → Playwright Sharp

microsoft / Playwright Sharp

Licence: mit
.NET version of the Playwright testing and automation library.

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Playwright Sharp

Playwright Go
Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.
Stars: ✭ 272 (-40.74%)
Mutual labels:  automation, firefox, chromium, webkit
Extension Create
Create modern cross-browser extensions with no build configuration.
Stars: ✭ 167 (-63.62%)
Mutual labels:  chrome, firefox, chromium
Sponsorblock
Skip YouTube video sponsors (browser extension)
Stars: ✭ 3,627 (+690.2%)
Mutual labels:  chrome, firefox, chromium
Playwright Python
Python version of the Playwright testing and automation library.
Stars: ✭ 5,583 (+1116.34%)
Mutual labels:  firefox, chromium, webkit
Chrome Export Passwords
Show all your chromium passwords in format ready to import in other browser like FireFox
Stars: ✭ 80 (-82.57%)
Mutual labels:  chrome, firefox, chromium
Kdeconnect Chrome Extension
A browser extension to send pages and content from your browser to connected KDE Connect devices.
Stars: ✭ 124 (-72.98%)
Mutual labels:  chrome, firefox, chromium
Tomato Clock
Tomato Clock is a simple browser extension for managing your productivity.
Stars: ✭ 241 (-47.49%)
Mutual labels:  chrome, firefox, chromium
Playwright
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Stars: ✭ 31,513 (+6765.58%)
Mutual labels:  firefox, chromium, webkit
Pychromeless
Python Lambda Chrome Automation (naming pending)
Stars: ✭ 219 (-52.29%)
Mutual labels:  automation, chrome, chromium
Cdp4j
cdp4j - Chrome DevTools Protocol for Java
Stars: ✭ 232 (-49.46%)
Mutual labels:  automation, chrome, chromium
mitm-play
Man in the middle using Playwright
Stars: ✭ 13 (-97.17%)
Mutual labels:  firefox, chromium, webkit
Uget Chrome Wrapper
Moved to https://github.com/ugetdm/uget-integrator and https://github.com/ugetdm/uget-extension
Stars: ✭ 74 (-83.88%)
Mutual labels:  chrome, firefox, chromium
Mue
Fast, open and free-to-use new tab page for modern browsers
Stars: ✭ 56 (-87.8%)
Mutual labels:  chrome, firefox, chromium
Surfingkeys Conf
A SurfingKeys configuration which adds 130+ key mappings for 20+ sites & OmniBar search suggestions for 50+ sites
Stars: ✭ 137 (-70.15%)
Mutual labels:  chrome, firefox, chromium
Web Media Controller
Allows controlling media player on different sites with Media Player widget on your desktop
Stars: ✭ 36 (-92.16%)
Mutual labels:  chrome, firefox, chromium
Qawolf
🐺 Create browser tests 10x faster
Stars: ✭ 2,912 (+534.42%)
Mutual labels:  chrome, firefox, webkit
Ferrum
Headless Chrome Ruby API
Stars: ✭ 1,009 (+119.83%)
Mutual labels:  automation, chrome, chromium
Melonjs
a fresh & lightweight javascript game engine
Stars: ✭ 3,721 (+710.68%)
Mutual labels:  chrome, firefox, webkit
Surfingkeys
Map your keys for web surfing, expand your browser with javascript and keyboard.
Stars: ✭ 3,787 (+725.05%)
Mutual labels:  chrome, firefox, chromium
Easy To Rss
🚀 Chrome/Firefox Extension to retreive RSS feeds URLs from WebSite, RSSHub supported
Stars: ✭ 386 (-15.9%)
Mutual labels:  chrome, firefox

🎭 Playwright for .NET NuGet version Join Slack

Website | .NET API reference

PlaywrightSharp is a .Net library to automate Chromium, Firefox and WebKit browsers with a single API. Playwright delivers automation that is ever-green, capable, reliable and fast. See how Playwright is better.

Linux macOS Windows
Chromium 90.0.4421.0
WebKit 14.0
Firefox 86.0b10

Headless execution is supported for all browsers on all platforms.

Usage

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
await page.GoToAsync("http://www.bing.com");
await page.ScreenshotAsync(path: outputFile);

Playwright Dependencies

Playwright Sharp relies on two external components: The Playwright driver and the browsers.

Playwright Driver

Playwright drivers will be copied to the bin folder at build time. Nuget will rely on the RuntimeIdentifier to copy a platform-specific driver, or on the runtime used on dotnet publish. If the RuntimeIdentifier is not set, all runtimes will be copied inside a runtimes folder. Then, the platform-specific driver will be picked at run-time.

Browsers

The way browsers are installed will vary depending on the use case scenario.

Playwright in test projects

If you use Playwright in test projects, all required browsers will be installed at build time.

Using Playwright in Docker

If you use the official Docker images, all the required browsers will be installed in that image. The minor version of the package will tell you which docker image tag to use. For instance, PlaywrightSharp 0.162.0 will work with the tag v1.6.2.

Using Playwright in a Remote Server.

If you run Playwright in a remote server. For instance, as part of a web application, you will need to run .\bin\playwright-cli.exe install in Windows or ./bin/playwright-cli install in OSX/Linux, as part of your deploy script.

Other possible scenarios.

If none of the scenarios mentioned above cover your scenario, you can install the browsers programmatically using await Playwright.InstallAsync();

Examples

Mobile and geolocation

This snippet emulates Mobile Safari on a device at a given geolocation, navigates to maps.google.com, performs an action, and takes a screenshot.

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Webkit.LaunchAsync(headless: false);

var contextOptions = playwright.Devices["iPhone 11 Pro"].ToBrowserContextOptions();
contextOptions.Locale = "en-US";
contextOptions.Geolocation = new Geolocation { Longitude = 12.492507m, Latitude = 41.889938m };
contextOptions.Permissions = new[] { ContextPermission.Geolocation };

var context = await browser.NewContextAsync(contextOptions);
var page = await context.NewPageAsync();
await page.GoToAsync("https://www.google.com/maps");

await page.ClickAsync(".ml-button-my-location-fab");
await page.WaitForLoadStateAsync(LifecycleEvent.Networkidle);

if ((await page.QuerySelectorAsync(".ml-promotion-no-thanks")) != null)
{
    await page.ClickAsync(".ml-promotion-no-thanks");
}

await page.ScreenshotAsync("colosseum-iphone.png");

Evaluate in browser context

This code snippet navigates to example.com in Firefox and executes a script in the page context.

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Firefox.LaunchAsync();

var context = await browser.NewContextAsync();
var page = await context.NewPageAsync();
await page.GoToAsync("https://www.example.com/");
var dimensions = await page.EvaluateAsync<Size>(@"() => {
    return {
        width: document.documentElement.clientWidth,
        height: document.documentElement.clientHeight,
    }
}");
Console.WriteLine(dimensions);

Intercept network requests

This code snippet sets up request routing for a WebKit page to log all network requests.

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Firefox.LaunchAsync();

var context = await browser.NewContextAsync();
var page = await context.NewPageAsync();
// Log and continue all network requests
await page.RouteAsync("**", (route, _) =>
{
    Console.WriteLine(route.Request.Url);
    route.ContinueAsync();
});

await page.GoToAsync("http://todomvc.com");

Monthly reports

Useful links

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].