Quellcode durchsuchen

Simple Playwright demo to open XKCD.com

Lukas Angerer vor 2 Jahren
Ursprung
Commit
7f9269ad38
4 geänderte Dateien mit 33 neuen und 1 gelöschten Zeilen
  1. 2 1
      .gitignore
  2. 14 0
      PlaywrightDemo/PlaywrightDemo.csproj
  3. 10 0
      PlaywrightDemo/Program.cs
  4. 7 0
      README.md

+ 2 - 1
.gitignore

@@ -5,7 +5,8 @@ project.lock.json
 *.pyc
 
 # Visual Studio Code
-.vscode
+.vscode/
+.idea/
 
 # User-specific files
 *.suo

+ 14 - 0
PlaywrightDemo/PlaywrightDemo.csproj

@@ -0,0 +1,14 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net7.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.Playwright" Version="1.39.0" />
+  </ItemGroup>
+
+</Project>

+ 10 - 0
PlaywrightDemo/Program.cs

@@ -0,0 +1,10 @@
+using System.Threading.Tasks;
+using Microsoft.Playwright;
+
+using var playwright = await Playwright.CreateAsync();
+await using var browser = await playwright.Chromium.LaunchAsync(new() { Headless = false });
+var page = await browser.NewPageAsync();
+await page.GotoAsync("https://xkcd.com");
+await page.ScreenshotAsync(new() { Path = "screenshot.png" });
+
+Console.ReadLine();

+ 7 - 0
README.md

@@ -0,0 +1,7 @@
+# Playwright Demo
+Shows basic capabilities of [Playwright for .NET](https://github.com/microsoft/playwright-dotnet).
+
+## Installation
+```ps1
+.\bin\Debug\net7.0\playwright.ps1 install chromium
+```