Exemplo n.º 1
0
        internal static async Task <Browser> CreateAsync(Connection connection, IBrowserOptions options,
                                                         Func <Task> closeCallBack)
        {
            var browser = new Browser(connection, options, closeCallBack);
            await connection.SendAsync("Target.setDiscoverTargets", new
            {
                discover = true
            });

            return(browser);
        }
Exemplo n.º 2
0
        public Browser(Connection connection, IBrowserOptions options, Func <Task> closeCallBack)
        {
            Connection          = connection;
            IgnoreHTTPSErrors   = options.IgnoreHTTPSErrors;
            AppMode             = options.AppMode;
            _targets            = new Dictionary <string, Target>();
            ScreenshotTaskQueue = new TaskQueue();

            Connection.Closed          += (object sender, EventArgs e) => Disconnected?.Invoke(this, new EventArgs());
            Connection.MessageReceived += Connect_MessageReceived;

            _closeCallBack = closeCallBack;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Browser"/> class.
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="options">The browser options</param>
        /// <param name="process">The chrome process</param>
        /// <param name="closeCallBack">An async function called before closing</param>
        public Browser(Connection connection, IBrowserOptions options, Process process, Func <Task> closeCallBack)
        {
            Process             = process;
            Connection          = connection;
            IgnoreHTTPSErrors   = options.IgnoreHTTPSErrors;
            AppMode             = options.AppMode;
            TargetsMap          = new Dictionary <string, Target>();
            ScreenshotTaskQueue = new TaskQueue();

            Connection.Closed          += (object sender, EventArgs e) => Disconnected?.Invoke(this, new EventArgs());
            Connection.MessageReceived += Connect_MessageReceived;

            _closeCallBack = closeCallBack;
            _logger        = Connection.LoggerFactory.CreateLogger <Browser>();
        }
Exemplo n.º 4
0
 public static void Init(IBrowserOptions browserOptions)
 {
     _browserOptions = browserOptions;
     IsInitalized    = true;
 }