Пример #1
0
 internal FirefoxBrowserContext(string browserContextId, FirefoxConnection connection, BrowserContextOptions browserContextOptions, FirefoxBrowser browser)
 {
     _browserContextId      = browserContextId;
     _connection            = connection;
     _browserContextOptions = browserContextOptions;
     _browser = browser;
 }
Пример #2
0
        /// <inheritdoc cref="IBrowserType.LaunchAsync(LaunchOptions)"/>
        public override async Task <IBrowser> LaunchAsync(LaunchOptions options = null)
        {
            var app = await LaunchBrowserAppAsync(options).ConfigureAwait(false);

            var connectOptions = app.ConnectOptions;

            return(await FirefoxBrowser.ConnectAsync(app, connectOptions).ConfigureAwait(false));
        }
Пример #3
0
        /// <inheritdoc cref="IBrowserType.ConnectAsync(ConnectOptions)"/>
        public override Task <IBrowser> ConnectAsync(ConnectOptions options = null)
        {
            if (options?.BrowserURL != null)
            {
                throw new PlaywrightSharpException("Option \"BrowserURL\" is not supported by Firefox");
            }

            return(FirefoxBrowser.ConnectAsync(options));
        }
Пример #4
0
        internal static async Task <IBrowser> ConnectAsync(IBrowserApp app, ConnectOptions options)
        {
            var transport = await BrowserHelper.CreateTransportAsync(options).ConfigureAwait(false);

            var connection = new FirefoxConnection(transport);
            var response   = await connection.SendAsync(new TargetGetBrowserContextsRequest()).ConfigureAwait(false);

            var browser = new FirefoxBrowser(app, connection, response.BrowserContextIds);
            await connection.SendAsync(new TargetEnableRequest()).ConfigureAwait(false);

            await browser.WaitForTargetAsync(t => t.Type == TargetType.Page).ConfigureAwait(false);

            return(browser);
        }
Пример #5
0
        public FirefoxTarget(FirefoxConnection connection, FirefoxBrowser firefoxBrowser, IBrowserContext context, string targetId, TargetInfoType type, string url, string openerId)
        {
            _connection = connection;
            _browser    = firefoxBrowser;
            _targetId   = targetId;
            _openerId   = openerId;

            BrowserContext = context;
            Type           = type switch
            {
                TargetInfoType.Browser => TargetType.Browser,
                TargetInfoType.Page => TargetType.Page,
                _ => throw new ArgumentOutOfRangeException(nameof(type))
            };
            Url = url;
        }