Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/Browser/ClientWindowInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Browser;

public sealed record ClientWindowInfo(bool Active, ClientWindow ClientWindow, ClientWindowState State, int Height, int Width, int X, int Y);

[JsonConverter(typeof(CamelCaseEnumConverter<ClientWindowState>))]
public enum ClientWindowState
{
Fullscreen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System;
using System.Text.Json.Serialization;

Expand All @@ -37,6 +38,7 @@ public sealed class CaptureScreenshotOptions : CommandOptions
public ClipRectangle? Clip { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<ScreenshotOrigin>))]
public enum ScreenshotOrigin
{
Viewport,
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/BrowsingContext/CreateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

Expand All @@ -35,6 +37,7 @@ public sealed class CreateOptions : CommandOptions
public Browser.UserContext? UserContext { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<ContextType>))]
public enum ContextType
{
Tab,
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/BrowsingContext/Locator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;
Expand Down Expand Up @@ -54,6 +55,7 @@ public sealed record AccessibilityValue

public sealed record ContextValue(BrowsingContext Context);

[JsonConverter(typeof(CamelCaseEnumConverter<MatchType>))]
public enum MatchType
{
Full,
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/BrowsingContext/NavigateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

Expand All @@ -31,6 +33,7 @@ public sealed class NavigateOptions : CommandOptions
public ReadinessState? Wait { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<ReadinessState>))]
public enum ReadinessState
{
None,
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/BrowsingContext/PrintCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

Expand Down Expand Up @@ -56,6 +58,7 @@ public struct PrintMargin
public double? Top { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<PrintOrientation>))]
public enum PrintOrientation
{
Portrait,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;
Expand All @@ -28,6 +29,7 @@ public sealed record UserPromptOpenedEventArgs(BiDi BiDi, BrowsingContext Contex
public string? DefaultValue { get; internal set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<UserPromptType>))]
public enum UserPromptType
{
Alert,
Expand Down
3 changes: 0 additions & 3 deletions dotnet/src/webdriver/BiDi/Communication/Broker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,11 @@ internal Broker(BiDi bidi, Uri url)
new InternalIdConverter(_bidi),
new PreloadScriptConverter(_bidi),
new RealmConverter(_bidi),
new RealmTypeConverter(),
new ScreenOrientationTypeConverter(),
new DateTimeOffsetConverter(),
new PrintPageRangeConverter(),
new InputOriginConverter(),
new WebExtensionConverter(_bidi),
new SubscriptionConverter(),
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase),

// https://github.com/dotnet/runtime/issues/72604
new Json.Converters.Polymorphic.EvaluateResultConverter(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// <copyright file="CamelCaseEnumConverter.cs" company="Selenium Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// </copyright>

using System;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters;

public class CamelCaseEnumConverter<TEnum>() :
JsonStringEnumConverter<TEnum>(JsonNamingPolicy.CamelCase) where TEnum : struct, Enum;
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Emulation;

Expand All @@ -35,6 +36,7 @@ public sealed class SetForcedColorsModeThemeOverrideOptions : CommandOptions
public IEnumerable<Browser.UserContext>? UserContexts { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<ForcedColorsModeTheme>))]
public enum ForcedColorsModeTheme
{
Light,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Emulation;

Expand All @@ -35,12 +36,14 @@ public sealed class SetScreenOrientationOverrideOptions : CommandOptions
public IEnumerable<Browser.UserContext>? UserContexts { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<ScreenOrientationNatural>))]
public enum ScreenOrientationNatural
{
Portrait,
Landscape
}

[JsonConverter(typeof(ScreenOrientationTypeConverter))]
public enum ScreenOrientationType
{
PortraitPrimary,
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/Input/SourceActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -144,6 +145,7 @@ public sealed record PointerParameters
public PointerType? PointerType { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<PointerType>))]
public enum PointerType
{
Mouse,
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/Log/LogEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Log;

Expand All @@ -42,6 +44,7 @@ public sealed record ConsoleLogEntry(BiDi BiDi, Level Level, Script.Source Sourc
public sealed record JavascriptLogEntry(BiDi BiDi, Level Level, Script.Source Source, string? Text, DateTimeOffset Timestamp)
: LogEntry(BiDi, Level, Source, Text, Timestamp);

[JsonConverter(typeof(CamelCaseEnumConverter<Level>))]
public enum Level
{
Debug,
Expand Down
6 changes: 5 additions & 1 deletion dotnet/src/webdriver/BiDi/Network/AddDataCollectorCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
// under the License.
// </copyright>

using System.Collections.Generic;
using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Network;

Expand All @@ -38,11 +40,13 @@ public class AddDataCollectorOptions : CommandOptions

public sealed record AddDataCollectorResult(Collector Collector) : EmptyResult;

[JsonConverter(typeof(CamelCaseEnumConverter<DataType>))]
public enum DataType
{
Response
}

[JsonConverter(typeof(CamelCaseEnumConverter<CollectorType>))]
public enum CollectorType
{
Blob
Expand Down
5 changes: 4 additions & 1 deletion dotnet/src/webdriver/BiDi/Network/AddInterceptCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
// under the License.
// </copyright>

using System.Collections.Generic;
using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Network;

Expand Down Expand Up @@ -48,6 +50,7 @@ public record BrowsingContextAddInterceptOptions

public sealed record AddInterceptResult(Intercept Intercept) : EmptyResult;

[JsonConverter(typeof(CamelCaseEnumConverter<InterceptPhase>))]
public enum InterceptPhase
{
BeforeRequestSent,
Expand Down
1 change: 1 addition & 0 deletions dotnet/src/webdriver/BiDi/Network/Cookie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace OpenQA.Selenium.BiDi.Network;

public sealed record Cookie(string Name, BytesValue Value, string Domain, string Path, long Size, bool HttpOnly, bool Secure, SameSite SameSite, [property: JsonConverter(typeof(DateTimeOffsetSecondsConverter))] DateTimeOffset? Expiry);

[JsonConverter(typeof(CamelCaseEnumConverter<SameSite>))]
public enum SameSite
{
Strict,
Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/Network/Initiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Network;

public sealed record Initiator(InitiatorType Type)
Expand All @@ -30,6 +33,7 @@ public sealed record Initiator(InitiatorType Type)
public Request? Request { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<InitiatorType>))]
public enum InitiatorType
{
Parser,
Expand Down
5 changes: 4 additions & 1 deletion dotnet/src/webdriver/BiDi/Network/SetCacheBehaviorCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
// under the License.
// </copyright>

using System.Collections.Generic;
using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Network;

Expand All @@ -44,6 +46,7 @@ internal SetCacheBehaviorOptions(BrowsingContextSetCacheBehaviorOptions? options

public sealed record BrowsingContextSetCacheBehaviorOptions;

[JsonConverter(typeof(CamelCaseEnumConverter<CacheBehavior>))]
public enum CacheBehavior
{
Default,
Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/Script/RealmType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Script;

[JsonConverter(typeof(RealmTypeConverter))]
public enum RealmType
{
Window,
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/Script/RemoteValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System;
using System.Collections.Generic;
using System.Numerics;
Expand Down Expand Up @@ -269,6 +270,7 @@ public sealed record WindowProxyRemoteValue(WindowProxyProperties Value) : Remot
public InternalId? InternalId { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<Mode>))]
public enum Mode
{
Open,
Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/Script/ResultOwnership.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Script;

[JsonConverter(typeof(CamelCaseEnumConverter<ResultOwnership>))]
public enum ResultOwnership
{
Root,
Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/Script/SerializationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Script;

public sealed class SerializationOptions
Expand All @@ -28,6 +31,7 @@ public sealed class SerializationOptions
public ShadowTree? IncludeShadowTree { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<ShadowTree>))]
public enum ShadowTree
{
None,
Expand Down
Loading