From 66a6c3f3613e8dc5f0e5f4c9d288ddb10aaa0180 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 8 Mar 2025 15:14:46 +0300 Subject: [PATCH 1/2] [dotnet][bidi] Added UnhandledPromptBehavior for new session capability --- .../Modules/Session/CapabilitiesRequest.cs | 2 +- .../BiDi/Modules/Session/CapabilityRequest.cs | 4 +- .../BiDi/Modules/Session/UserPromptHandler.cs | 42 +++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 dotnet/src/webdriver/BiDi/Modules/Session/UserPromptHandler.cs diff --git a/dotnet/src/webdriver/BiDi/Modules/Session/CapabilitiesRequest.cs b/dotnet/src/webdriver/BiDi/Modules/Session/CapabilitiesRequest.cs index df1b8498786bc..3740ce75cbb1f 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Session/CapabilitiesRequest.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Session/CapabilitiesRequest.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Modules.Session; -public class CapabilitiesRequest +public record CapabilitiesRequest { public CapabilityRequest? AlwaysMatch { get; set; } diff --git a/dotnet/src/webdriver/BiDi/Modules/Session/CapabilityRequest.cs b/dotnet/src/webdriver/BiDi/Modules/Session/CapabilityRequest.cs index e035f1f9687bc..a5878f7597768 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Session/CapabilityRequest.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Session/CapabilityRequest.cs @@ -19,7 +19,7 @@ namespace OpenQA.Selenium.BiDi.Modules.Session; -public class CapabilityRequest +public record CapabilityRequest { public bool? AcceptInsecureCerts { get; set; } @@ -31,5 +31,5 @@ public class CapabilityRequest public ProxyConfiguration? ProxyConfiguration { get; set; } - public bool? WebSocketUrl { get; set; } + public UserPromptHandler? UnhandledPromptBehavior { get; set; } } diff --git a/dotnet/src/webdriver/BiDi/Modules/Session/UserPromptHandler.cs b/dotnet/src/webdriver/BiDi/Modules/Session/UserPromptHandler.cs new file mode 100644 index 0000000000000..edd7a815aeb36 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Modules/Session/UserPromptHandler.cs @@ -0,0 +1,42 @@ +// +// 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. +// + +namespace OpenQA.Selenium.BiDi.Modules.Session; + +public record UserPromptHandler +{ + public UserPromptHandlerType? Alert { get; set; } + + public UserPromptHandlerType? BeforeUnload { get; set; } + + public UserPromptHandlerType? Confirm { get; set; } + + public UserPromptHandlerType? Default { get; set; } + + public UserPromptHandlerType? File { get; set; } + + public UserPromptHandlerType? Prompt { get; set; } +} + +public enum UserPromptHandlerType +{ + Accept, + Dismiss, + Ignore +} From d8ea5f11aa987104ed713785c4ea2a1344450656 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 8 Mar 2025 15:21:11 +0300 Subject: [PATCH 2/2] Update UserPromptOpenedEventArgs.cs --- .../BiDi/Modules/BrowsingContext/UserPromptOpenedEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/UserPromptOpenedEventArgs.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/UserPromptOpenedEventArgs.cs index e6b8a1541c0c6..2a748c34a3c9c 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/UserPromptOpenedEventArgs.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/UserPromptOpenedEventArgs.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -public record UserPromptOpenedEventArgs(BiDi BiDi, BrowsingContext Context, UserPromptType Type, string Message) +public record UserPromptOpenedEventArgs(BiDi BiDi, BrowsingContext Context, Session.UserPromptHandlerType Handler, UserPromptType Type, string Message) : BrowsingContextEventArgs(BiDi, Context) { [JsonInclude]