-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace Demo.WebBrowsers.Playwright; | ||
|
||
using Microsoft.Playwright; | ||
using NBomber.CSharp; | ||
using NBomber.WebBrowser.Playwright; | ||
|
||
public class PlaywrightExample | ||
{ | ||
public async Task Run() | ||
{ | ||
var browserPath = "C:/Program Files/Google/Chrome/Application/chrome.exe"; | ||
|
||
using var playwright = await Playwright.CreateAsync(); | ||
|
||
await using var browser = await playwright.Chromium.LaunchAsync( | ||
new BrowserTypeLaunchOptions { Headless = true, ExecutablePath = browserPath } | ||
); | ||
|
||
var scenario = Scenario.Create("playwright_scenario", async context => | ||
{ | ||
var page = await browser.NewPageAsync(); | ||
var pageResponse = await page.GotoAsync("https://translate.google.com/"); | ||
|
||
var response = await pageResponse.ToNBomberResponse(); | ||
page.CloseAsync(); | ||
Check warning on line 25 in examples/Demo/WebBrowsers/Playwright/PlaywrightExample.cs GitHub Actions / build
|
||
|
||
return response; | ||
}) | ||
.WithoutWarmUp() | ||
.WithLoadSimulations( | ||
Simulation.KeepConstant(1, TimeSpan.FromMinutes(1)) | ||
); | ||
|
||
NBomberRunner | ||
.RegisterScenarios(scenario) | ||
.Run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace Demo.WebBrowsers.Puppeteer; | ||
|
||
using PuppeteerSharp; | ||
using NBomber.CSharp; | ||
using NBomber.WebBrowser.PuppeteerSharp; | ||
|
||
public class PuppeteerExample | ||
{ | ||
public async Task Run() | ||
{ | ||
var browserPath = "C:/Program Files/Google/Chrome/Application/chrome.exe"; | ||
|
||
await using var browser = await Puppeteer.LaunchAsync( | ||
new LaunchOptions { Headless = true, ExecutablePath = browserPath } | ||
); | ||
|
||
var scenario = Scenario.Create("puppeteer_scenario", async context => | ||
{ | ||
await using var page = await browser.NewPageAsync(); | ||
var pageResponse = await page.GoToAsync("https://translate.google.com/"); | ||
|
||
var response = await pageResponse.ToNBomberResponse(); | ||
page.CloseAsync(); | ||
Check warning on line 23 in examples/Demo/WebBrowsers/Puppeteer/PuppeteerExample.cs GitHub Actions / build
|
||
|
||
return response; | ||
}) | ||
.WithoutWarmUp() | ||
.WithLoadSimulations( | ||
Simulation.KeepConstant(1, TimeSpan.FromSeconds(60)) | ||
); | ||
|
||
NBomberRunner | ||
.RegisterScenarios(scenario) | ||
.Run(); | ||
} | ||
} |