private async Task <(TempDirectory tmp, IBrowserContext context, IPage page)> LaunchPersistentAsync(BrowserTypeLaunchPersistentContextOptions options = null) { var tmp = new TempDirectory(); var context = await BrowserType.LaunchPersistentContextAsync( tmp.Path, options : options); var page = context.Pages.First(); return(tmp, context, page); }
public async Task <IBrowserContext> LaunchPersistentContextAsync(string userDataDir, BrowserTypeLaunchPersistentContextOptions options = default) { options ??= new BrowserTypeLaunchPersistentContextOptions(); var context = (await _channel.LaunchPersistentContextAsync( userDataDir, headless: options.Headless, channel: options.Channel, executablePath: options.ExecutablePath, args: options.Args, proxy: options.Proxy, downloadsPath: options.DownloadsPath, tracesDir: options.TracesDir, chromiumSandbox: options.ChromiumSandbox, handleSIGINT: options.HandleSIGINT, handleSIGTERM: options.HandleSIGTERM, handleSIGHUP: options.HandleSIGHUP, timeout: options.Timeout, env: options.Env, devtools: options.Devtools, slowMo: options.SlowMo, acceptDownloads: options.AcceptDownloads, ignoreHTTPSErrors: options.IgnoreHTTPSErrors, bypassCSP: options.BypassCSP, viewportSize: options.ViewportSize, screenSize: options.ScreenSize, userAgent: options.UserAgent, deviceScaleFactor: options.DeviceScaleFactor, isMobile: options.IsMobile, hasTouch: options.HasTouch, javaScriptEnabled: options.JavaScriptEnabled, timezoneId: options.TimezoneId, geolocation: options.Geolocation, locale: options.Locale, permissions: options.Permissions, extraHTTPHeaders: options.ExtraHTTPHeaders, offline: options.Offline, httpCredentials: options.HttpCredentials, colorScheme: options.ColorScheme, reducedMotion: options.ReducedMotion, recordHarPath: options.RecordHarPath, recordHarOmitContent: options.RecordHarOmitContent, recordVideo: Browser.GetVideoArgs(options.RecordVideoDir, options.RecordVideoSize), ignoreDefaultArgs: options.IgnoreDefaultArgs, ignoreAllDefaultArgs: options.IgnoreAllDefaultArgs, baseUrl: options.BaseURL, forcedColors: options.ForcedColors).ConfigureAwait(false)).Object; // TODO: unite with a single browser context options type which is derived from channels context.Options = new() { RecordVideoDir = options.RecordVideoDir, RecordVideoSize = options.RecordVideoSize, RecordHarPath = options.RecordHarPath, RecordHarOmitContent = options.RecordHarOmitContent, }; ((Core.Tracing)context.Tracing).LocalUtils = Playwright.Utils; return(context); }