internal Dictionary <string, object> ToChannelDictionary()
        {
            var args = new Dictionary <string, object>();

            if (Viewport == null)
            {
                args["noDefaultViewport"] = true;
            }
            else if (!Viewport.Equals(ViewportSize.None))
            {
                args["viewport"] = Viewport;
            }

            if (!string.IsNullOrEmpty(UserAgent))
            {
                args["userAgent"] = UserAgent;
            }

            if (BypassCSP != null)
            {
                args["bypassCSP"] = BypassCSP;
            }

            if (JavaScriptEnabled != null)
            {
                args["javaScriptEnabled"] = JavaScriptEnabled;
            }

            if (IgnoreHTTPSErrors != null)
            {
                args["ignoreHTTPSErrors"] = IgnoreHTTPSErrors;
            }

            if (!string.IsNullOrEmpty(TimezoneId))
            {
                args["timezoneId"] = TimezoneId;
            }

            if (Geolocation != null)
            {
                args["geolocation"] = Geolocation;
            }

            if (Permissions != null)
            {
                args["permissions"] = Permissions;
            }

            if (IsMobile != null)
            {
                args["isMobile"] = IsMobile;
            }

            if (Offline != null)
            {
                args["offline"] = Offline;
            }

            if (DeviceScaleFactor != null)
            {
                args["deviceScaleFactor"] = DeviceScaleFactor;
            }

            if (HttpCredentials != null)
            {
                args["httpCredentials"] = HttpCredentials;
            }

            if (HasTouch != null)
            {
                args["hasTouch"] = HasTouch;
            }

            if (AcceptDownloads != null)
            {
                args["acceptDownloads"] = AcceptDownloads;
            }

            if (ColorScheme != null)
            {
                args["colorScheme"] = ColorScheme;
            }

            if (Locale != null)
            {
                args["locale"] = Locale;
            }

            if (ExtraHTTPHeaders != null)
            {
                args["extraHTTPHeaders"] = ExtraHTTPHeaders.Select(kv => new HeaderEntry {
                    Name = kv.Key, Value = kv.Value
                }).ToArray();
            }

            if (RecordHar != null)
            {
                args["recordHar"] = RecordHar;
            }

            if (RecordVideo != null)
            {
                args["recordVideo"] = RecordVideo;
            }

            if (Proxy != null)
            {
                args["proxy"] = Proxy;
            }

            if (!string.IsNullOrEmpty(StorageStatePath))
            {
                StorageState = JsonSerializer.Deserialize <StorageState>(File.ReadAllText(StorageStatePath), JsonExtensions.DefaultJsonSerializerOptions);
            }

            if (StorageState != null)
            {
                args["storageState"] = StorageState;
            }

            return(args);
        }
        internal override Dictionary <string, object> ToChannelDictionary()
        {
            var args = base.ToChannelDictionary();

            if (Viewport == null)
            {
                args["noDefaultViewport"] = true;
            }
            else if (!Viewport.Equals(ViewportSize.None))
            {
                args["viewport"] = Viewport;
            }

            if (!string.IsNullOrEmpty(UserAgent))
            {
                args["userAgent"] = UserAgent;
            }

            if (BypassCSP != null)
            {
                args["bypassCSP"] = BypassCSP;
            }

            if (JavaScriptEnabled != null)
            {
                args["javaScriptEnabled"] = JavaScriptEnabled;
            }

            if (IgnoreHTTPSErrors != null)
            {
                args["ignoreHTTPSErrors"] = IgnoreHTTPSErrors;
            }

            if (!string.IsNullOrEmpty(TimezoneId))
            {
                args["timezoneId"] = TimezoneId;
            }

            if (Geolocation != null)
            {
                args["geolocation"] = Geolocation;
            }

            if (Permissions != null)
            {
                args["permissions"] = Permissions;
            }

            if (IsMobile != null)
            {
                args["isMobile"] = IsMobile;
            }

            if (Offline != null)
            {
                args["offline"] = Offline;
            }

            if (DeviceScaleFactor != null)
            {
                args["deviceScaleFactor"] = DeviceScaleFactor;
            }

            if (HttpCredentials != null)
            {
                args["httpCredentials"] = HttpCredentials;
            }

            if (HasTouch != null)
            {
                args["hasTouch"] = HasTouch;
            }

            if (AcceptDownloads != null)
            {
                args["acceptDownloads"] = AcceptDownloads;
            }

            if (ColorScheme != null)
            {
                args["colorScheme"] = ColorScheme;
            }

            if (Locale != null)
            {
                args["locale"] = Locale;
            }

            if (ExtraHTTPHeaders != null)
            {
                args["extraHTTPHeaders"] = ExtraHTTPHeaders.Select(kv => new HeaderEntry {
                    Name = kv.Key, Value = kv.Value
                }).ToArray();
            }

            if (RecordHar != null)
            {
                args["recordHar"] = RecordHar;
            }

            if (RecordVideo != null)
            {
                args["recordVideo"] = RecordVideo;
            }

            args["sdkLanguage"] = "csharp";

            return(args);
        }