diff --git a/dotnet/src/webdriver/BiDi/Communication/Broker.cs b/dotnet/src/webdriver/BiDi/Communication/Broker.cs index f0c0f2c279f91..db2058224749b 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Broker.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Broker.cs @@ -84,7 +84,6 @@ internal Broker(BiDi bidi, Uri url) new RealmConverter(_bidi), new RealmTypeConverter(), new DateTimeOffsetConverter(), - new TimeSpanConverter(), new PrintPageRangeConverter(), new InputOriginConverter(), new WebExtensionConverter(_bidi), diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/DateTimeOffsetConverter.cs b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/DateTimeOffsetConverter.cs index e3b2b57ffe4f4..4ffa57f627bba 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/DateTimeOffsetConverter.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/DateTimeOffsetConverter.cs @@ -27,7 +27,16 @@ internal class DateTimeOffsetConverter : JsonConverter { public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - return DateTimeOffset.FromUnixTimeMilliseconds(reader.GetInt64()); + // Workaround: it should be Int64, chrome uses double for `expiry` like "expiry":1737379944.308351 + + if (reader.TryGetInt64(out long unixTime) is false) + { + var doubleValue = reader.GetDouble(); + + unixTime = Convert.ToInt64(doubleValue); + } + + return DateTimeOffset.FromUnixTimeMilliseconds(unixTime); } public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options) diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/TimeSpanConverter.cs b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/TimeSpanConverter.cs deleted file mode 100644 index 8bb6717f2391c..0000000000000 --- a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/TimeSpanConverter.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -// 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. -// - -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace OpenQA.Selenium.BiDi.Communication.Json.Converters; - -internal class TimeSpanConverter : JsonConverter -{ - public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TryGetInt64(out long milliseconds) is false) - { - var doubleValue = reader.GetDouble(); - - milliseconds = Convert.ToInt64(doubleValue); - } - - return TimeSpan.FromMilliseconds(milliseconds); - } - - public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options) - { - writer.WriteNumberValue(value.TotalMilliseconds); - } -} diff --git a/dotnet/src/webdriver/BiDi/Network/Cookie.cs b/dotnet/src/webdriver/BiDi/Network/Cookie.cs index 972e02541f1d8..226f03ec36e64 100644 --- a/dotnet/src/webdriver/BiDi/Network/Cookie.cs +++ b/dotnet/src/webdriver/BiDi/Network/Cookie.cs @@ -18,10 +18,15 @@ // using System; +using System.Text.Json.Serialization; 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, TimeSpan? Expiry); +public sealed record Cookie(string Name, BytesValue Value, string Domain, string Path, long Size, bool HttpOnly, bool Secure, SameSite SameSite) +{ + [JsonInclude] + public DateTimeOffset? Expiry { get; internal set; } +} public enum SameSite {