From 0b164170c45917e15a8fd8f115cdede4e1dfc6e8 Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Thu, 31 Aug 2023 13:01:41 -0400 Subject: [PATCH 001/141] [dotnet] Fixing POST requests during test for .NET Framework 4.8 --- dotnet/test/common/Environment/UrlBuilder.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dotnet/test/common/Environment/UrlBuilder.cs b/dotnet/test/common/Environment/UrlBuilder.cs index 04262ba86466c..01f1864dad3bc 100644 --- a/dotnet/test/common/Environment/UrlBuilder.cs +++ b/dotnet/test/common/Environment/UrlBuilder.cs @@ -109,9 +109,11 @@ public string CreateInlinePage(InlinePage page) payloadDictionary["content"] = page.ToString(); string commandPayload = JsonConvert.SerializeObject(payloadDictionary); byte[] data = Encoding.UTF8.GetBytes(commandPayload); + HttpWebRequest request = HttpWebRequest.Create(createPageUri) as HttpWebRequest; request.Method = "POST"; request.ContentType = "application/json;charset=utf8"; + request.ServicePoint.Expect100Continue = false; Stream requestStream = request.GetRequestStream(); requestStream.Write(data, 0, data.Length); requestStream.Close(); From 05c148f052e547f06dd6569c21450d2c0f320b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sautter?= Date: Thu, 31 Aug 2023 19:21:03 +0200 Subject: [PATCH 002/141] [java] directly iterate http headers --- .../selenium/devtools/v114/v114Network.java | 18 +++---- .../selenium/devtools/v115/v115Network.java | 23 +++++---- .../selenium/devtools/v116/v116Network.java | 23 +++++---- .../selenium/devtools/v85/V85Network.java | 18 +++---- .../grid/web/ReverseProxyHandler.java | 20 ++++---- .../netty/server/ResponseConverter.java | 22 ++++----- .../remote/http/DumpHttpExchangeFilter.java | 15 +----- .../selenium/remote/http/HttpMessage.java | 49 +++++++++++++++++++ .../openqa/selenium/remote/http/Route.java | 16 +++--- .../remote/http/jdk/JdkHttpMessages.java | 27 +++++----- .../http/netty/NettyDomainSocketClient.java | 4 +- .../remote/http/netty/NettyMessages.java | 6 +-- .../netty/server/NettyServerTest.java | 6 +-- 13 files changed, 127 insertions(+), 120 deletions(-) diff --git a/java/src/org/openqa/selenium/devtools/v114/v114Network.java b/java/src/org/openqa/selenium/devtools/v114/v114Network.java index 68eade5d83746..49ef921f2edb8 100644 --- a/java/src/org/openqa/selenium/devtools/v114/v114Network.java +++ b/java/src/org/openqa/selenium/devtools/v114/v114Network.java @@ -25,8 +25,8 @@ import java.io.IOException; import java.io.InputStream; import java.util.AbstractMap; +import java.util.ArrayList; import java.util.Base64; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -148,7 +148,7 @@ public Either createSeMessages(RequestPaused pausedRe bodyIsBase64Encoded = false; } - List> headers = new LinkedList<>(); + List> headers = new ArrayList<>(); pausedReq .getResponseHeaders() .ifPresent( @@ -198,11 +198,8 @@ protected Command continueRequest(RequestPaused pausedReq, HttpRequest req return continueWithoutModification(pausedReq); } - List headers = new LinkedList<>(); - req.getHeaderNames() - .forEach( - name -> - req.getHeaders(name).forEach(value -> headers.add(new HeaderEntry(name, value)))); + List headers = new ArrayList<>(); + req.forEachHeader((name, value) -> headers.add(new HeaderEntry(name, value))); return Fetch.continueRequest( pausedReq.getRequestId(), @@ -215,11 +212,8 @@ protected Command continueRequest(RequestPaused pausedReq, HttpRequest req @Override protected Command fulfillRequest(RequestPaused pausedReq, HttpResponse res) { - List headers = new LinkedList<>(); - res.getHeaderNames() - .forEach( - name -> - res.getHeaders(name).forEach(value -> headers.add(new HeaderEntry(name, value)))); + List headers = new ArrayList<>(); + res.forEachHeader((name, value) -> headers.add(new HeaderEntry(name, value))); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (InputStream is = res.getContent().get()) { diff --git a/java/src/org/openqa/selenium/devtools/v115/v115Network.java b/java/src/org/openqa/selenium/devtools/v115/v115Network.java index bf449f801a161..d7b89012207f4 100644 --- a/java/src/org/openqa/selenium/devtools/v115/v115Network.java +++ b/java/src/org/openqa/selenium/devtools/v115/v115Network.java @@ -24,7 +24,12 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.*; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Base64; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.logging.Logger; import org.openqa.selenium.UsernameAndPassword; import org.openqa.selenium.devtools.Command; @@ -138,7 +143,7 @@ public Either createSeMessages(RequestPaused pausedRe bodyIsBase64Encoded = false; } - List> headers = new LinkedList<>(); + List> headers = new ArrayList<>(); pausedReq .getResponseHeaders() .ifPresent( @@ -188,11 +193,8 @@ protected Command continueRequest(RequestPaused pausedReq, HttpRequest req return continueWithoutModification(pausedReq); } - List headers = new LinkedList<>(); - req.getHeaderNames() - .forEach( - name -> - req.getHeaders(name).forEach(value -> headers.add(new HeaderEntry(name, value)))); + List headers = new ArrayList<>(); + req.forEachHeader((name, value) -> headers.add(new HeaderEntry(name, value))); return Fetch.continueRequest( pausedReq.getRequestId(), @@ -205,11 +207,8 @@ protected Command continueRequest(RequestPaused pausedReq, HttpRequest req @Override protected Command fulfillRequest(RequestPaused pausedReq, HttpResponse res) { - List headers = new LinkedList<>(); - res.getHeaderNames() - .forEach( - name -> - res.getHeaders(name).forEach(value -> headers.add(new HeaderEntry(name, value)))); + List headers = new ArrayList<>(); + res.forEachHeader((name, value) -> headers.add(new HeaderEntry(name, value))); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (InputStream is = res.getContent().get()) { diff --git a/java/src/org/openqa/selenium/devtools/v116/v116Network.java b/java/src/org/openqa/selenium/devtools/v116/v116Network.java index ebc1502dfc641..24935d6bb97f5 100644 --- a/java/src/org/openqa/selenium/devtools/v116/v116Network.java +++ b/java/src/org/openqa/selenium/devtools/v116/v116Network.java @@ -24,7 +24,12 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.*; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Base64; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.logging.Logger; import org.openqa.selenium.UsernameAndPassword; import org.openqa.selenium.devtools.Command; @@ -138,7 +143,7 @@ public Either createSeMessages(RequestPaused pausedRe bodyIsBase64Encoded = false; } - List> headers = new LinkedList<>(); + List> headers = new ArrayList<>(); pausedReq .getResponseHeaders() .ifPresent( @@ -188,11 +193,8 @@ protected Command continueRequest(RequestPaused pausedReq, HttpRequest req return continueWithoutModification(pausedReq); } - List headers = new LinkedList<>(); - req.getHeaderNames() - .forEach( - name -> - req.getHeaders(name).forEach(value -> headers.add(new HeaderEntry(name, value)))); + List headers = new ArrayList<>(); + req.forEachHeader((name, value) -> headers.add(new HeaderEntry(name, value))); return Fetch.continueRequest( pausedReq.getRequestId(), @@ -205,11 +207,8 @@ protected Command continueRequest(RequestPaused pausedReq, HttpRequest req @Override protected Command fulfillRequest(RequestPaused pausedReq, HttpResponse res) { - List headers = new LinkedList<>(); - res.getHeaderNames() - .forEach( - name -> - res.getHeaders(name).forEach(value -> headers.add(new HeaderEntry(name, value)))); + List headers = new ArrayList<>(); + res.forEachHeader((name, value) -> headers.add(new HeaderEntry(name, value))); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (InputStream is = res.getContent().get()) { diff --git a/java/src/org/openqa/selenium/devtools/v85/V85Network.java b/java/src/org/openqa/selenium/devtools/v85/V85Network.java index 7ba9dd3120deb..e365534045ed1 100644 --- a/java/src/org/openqa/selenium/devtools/v85/V85Network.java +++ b/java/src/org/openqa/selenium/devtools/v85/V85Network.java @@ -25,8 +25,8 @@ import java.io.IOException; import java.io.InputStream; import java.util.AbstractMap; +import java.util.ArrayList; import java.util.Base64; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -148,7 +148,7 @@ public Either createSeMessages(RequestPaused pausedRe bodyIsBase64Encoded = false; } - List> headers = new LinkedList<>(); + List> headers = new ArrayList<>(); pausedReq .getResponseHeaders() .ifPresent( @@ -197,11 +197,8 @@ protected Command continueRequest(RequestPaused pausedReq, HttpRequest req return continueWithoutModification(pausedReq); } - List headers = new LinkedList<>(); - req.getHeaderNames() - .forEach( - name -> - req.getHeaders(name).forEach(value -> headers.add(new HeaderEntry(name, value)))); + List headers = new ArrayList<>(); + req.forEachHeader((name, value) -> headers.add(new HeaderEntry(name, value))); return Fetch.continueRequest( pausedReq.getRequestId(), @@ -213,11 +210,8 @@ protected Command continueRequest(RequestPaused pausedReq, HttpRequest req @Override protected Command fulfillRequest(RequestPaused pausedReq, HttpResponse res) { - List headers = new LinkedList<>(); - res.getHeaderNames() - .forEach( - name -> - res.getHeaders(name).forEach(value -> headers.add(new HeaderEntry(name, value)))); + List headers = new ArrayList<>(); + res.forEachHeader((name, value) -> headers.add(new HeaderEntry(name, value))); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (InputStream is = res.getContent().get()) { diff --git a/java/src/org/openqa/selenium/grid/web/ReverseProxyHandler.java b/java/src/org/openqa/selenium/grid/web/ReverseProxyHandler.java index 6b3c4fe464c3c..dfe5fbe71ca7f 100644 --- a/java/src/org/openqa/selenium/grid/web/ReverseProxyHandler.java +++ b/java/src/org/openqa/selenium/grid/web/ReverseProxyHandler.java @@ -75,15 +75,13 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException { } } - for (String name : req.getHeaderNames()) { - if (IGNORED_REQ_HEADERS.contains(name.toLowerCase())) { - continue; - } - - for (String value : req.getHeaders(name)) { - toUpstream.addHeader(name, value); - } - } + req.forEachHeader( + (name, value) -> { + if (IGNORED_REQ_HEADERS.contains(name.toLowerCase())) { + return; + } + toUpstream.addHeader(name, value); + }); // None of this "keep alive" nonsense. toUpstream.setHeader("Connection", "keep-alive"); @@ -93,8 +91,8 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException { HTTP_RESPONSE.accept(span, resp); // clear response defaults. - resp.removeHeader("Date"); - resp.removeHeader("Server"); + resp.removeHeader("date"); + resp.removeHeader("server"); IGNORED_REQ_HEADERS.forEach(resp::removeHeader); diff --git a/java/src/org/openqa/selenium/netty/server/ResponseConverter.java b/java/src/org/openqa/selenium/netty/server/ResponseConverter.java index 79bc1dc2c25a4..8bf5ebe9bf76b 100644 --- a/java/src/org/openqa/selenium/netty/server/ResponseConverter.java +++ b/java/src/org/openqa/selenium/netty/server/ResponseConverter.java @@ -96,18 +96,16 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) } private void copyHeaders(HttpResponse seResponse, DefaultHttpResponse first) { - for (String name : seResponse.getHeaderNames()) { - if (CONTENT_LENGTH.contentEqualsIgnoreCase(name) - || TRANSFER_ENCODING.contentEqualsIgnoreCase(name)) { - continue; - } - for (String value : seResponse.getHeaders(name)) { - if (value == null) { - continue; - } - first.headers().add(name, value); - } - } + seResponse.forEachHeader( + (name, value) -> { + if (CONTENT_LENGTH.contentEqualsIgnoreCase(name) + || TRANSFER_ENCODING.contentEqualsIgnoreCase(name)) { + return; + } else if (value == null) { + return; + } + first.headers().add(name, value); + }); if (allowCors) { first.headers().add("Access-Control-Allow-Origin", "*"); diff --git a/java/src/org/openqa/selenium/remote/http/DumpHttpExchangeFilter.java b/java/src/org/openqa/selenium/remote/http/DumpHttpExchangeFilter.java index f466c095a43c7..a614ceac66ab8 100644 --- a/java/src/org/openqa/selenium/remote/http/DumpHttpExchangeFilter.java +++ b/java/src/org/openqa/selenium/remote/http/DumpHttpExchangeFilter.java @@ -17,14 +17,11 @@ package org.openqa.selenium.remote.http; -import static java.util.stream.Collectors.joining; - import com.google.common.annotations.VisibleForTesting; import java.io.InputStream; import java.util.function.Supplier; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.StreamSupport; import org.openqa.selenium.internal.Debug; import org.openqa.selenium.internal.Require; @@ -56,16 +53,8 @@ public HttpHandler apply(HttpHandler next) { } private void expandHeadersAndContent(StringBuilder builder, HttpMessage message) { - message - .getHeaderNames() - .forEach( - name -> { - builder.append(" ").append(name).append(": "); - builder.append( - StreamSupport.stream(message.getHeaders(name).spliterator(), false) - .collect(joining(", "))); - builder.append("\n"); - }); + message.forEachHeader( + (name, value) -> builder.append(" ").append(name).append(": ").append(value).append("\n")); builder.append("\n"); builder.append(Contents.string(message)); } diff --git a/java/src/org/openqa/selenium/remote/http/HttpMessage.java b/java/src/org/openqa/selenium/remote/http/HttpMessage.java index c46e55e9772ac..d5d4fbfccf911 100644 --- a/java/src/org/openqa/selenium/remote/http/HttpMessage.java +++ b/java/src/org/openqa/selenium/remote/http/HttpMessage.java @@ -30,6 +30,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.function.BiConsumer; import java.util.function.Supplier; import java.util.stream.Collectors; import org.openqa.selenium.internal.Require; @@ -65,10 +66,30 @@ public Iterable getAttributeNames() { return ImmutableSet.copyOf(attributes.keySet()); } + /** + * Calls the {@code action} for all headers set. + * + * @param action the action to call + */ + public void forEachHeader(BiConsumer action) { + headers.forEach(action); + } + + /** + * Returns an iterable with all the names of the headers set. + * + * @return an iterable view of the header names + */ public Iterable getHeaderNames() { return Collections.unmodifiableCollection(headers.keySet()); } + /** + * Returns an iterable of the values of headers with the {@code name} (case-insensitive). + * + * @param name the name of the header, case-insensitive + * @return an iterable view of the values + */ public Iterable getHeaders(String name) { return headers.entries().stream() .filter(e -> Objects.nonNull(e.getKey())) @@ -77,6 +98,12 @@ public Iterable getHeaders(String name) { .collect(Collectors.toList()); } + /** + * Returns the value of the first header with the {@code name} (case-insensitive). + * + * @param name the name of the header, case-insensitive + * @return the value + */ public String getHeader(String name) { return headers.entries().stream() .filter(e -> Objects.nonNull(e.getKey())) @@ -86,15 +113,37 @@ public String getHeader(String name) { .orElse(null); } + /** + * Removes all headers with the {@code name} (case-insensitive) and adds a header with the {@code + * value}. + * + * @param name the name of the header, case-insensitive + * @param value the value to set + * @return self + */ public M setHeader(String name, String value) { return removeHeader(name).addHeader(name, value); } + /** + * Adds a header with the {@code name} and {@code value}, headers with the same (case-insensitive) + * name will be preserved. + * + * @param name the name of the header, case-insensitive + * @param value the value to set + * @return self + */ public M addHeader(String name, String value) { headers.put(name, value); return self(); } + /** + * Removes all headers with the {@code name} (case-insensitive). + * + * @param name the name of the header, case-insensitive + * @return self + */ public M removeHeader(String name) { headers.keySet().removeIf(header -> header.equalsIgnoreCase(name)); return self(); diff --git a/java/src/org/openqa/selenium/remote/http/Route.java b/java/src/org/openqa/selenium/remote/http/Route.java index 88befa3fd0031..8d355b39cd017 100644 --- a/java/src/org/openqa/selenium/remote/http/Route.java +++ b/java/src/org/openqa/selenium/remote/http/Route.java @@ -278,15 +278,13 @@ private HttpRequest transform(HttpRequest request) { HttpRequest toForward = new HttpRequest(request.getMethod(), unprefixed); - request - .getHeaderNames() - .forEach( - name -> { - if (name == null) { - return; - } - request.getHeaders(name).forEach(value -> toForward.addHeader(name, value)); - }); + request.forEachHeader( + (name, value) -> { + if (name == null) { + return; + } + toForward.addHeader(name, value); + }); request .getAttributeNames() diff --git a/java/src/org/openqa/selenium/remote/http/jdk/JdkHttpMessages.java b/java/src/org/openqa/selenium/remote/http/jdk/JdkHttpMessages.java index 0d0837f159c50..ad44af7703f0c 100644 --- a/java/src/org/openqa/selenium/remote/http/jdk/JdkHttpMessages.java +++ b/java/src/org/openqa/selenium/remote/http/jdk/JdkHttpMessages.java @@ -72,19 +72,19 @@ public java.net.http.HttpRequest createRequest(HttpRequest req, HttpMethod metho switch (method) { case DELETE: - builder = builder.DELETE(); + builder.DELETE(); break; case GET: - builder = builder.GET(); + builder.GET(); break; case POST: - builder = builder.POST(notChunkingBodyPublisher(req)); + builder.POST(notChunkingBodyPublisher(req)); break; case PUT: - builder = builder.PUT(notChunkingBodyPublisher(req)); + builder.PUT(notChunkingBodyPublisher(req)); break; default: @@ -92,18 +92,17 @@ public java.net.http.HttpRequest createRequest(HttpRequest req, HttpMethod metho String.format("Unsupported request method %s: %s", req.getMethod(), req)); } - for (String name : req.getHeaderNames()) { - // This prevents the IllegalArgumentException that states 'restricted header name: ...' - if (IGNORE_HEADERS.contains(name.toLowerCase())) { - continue; - } - for (String value : req.getHeaders(name)) { - builder = builder.header(name, value); - } - } + req.forEachHeader( + (name, value) -> { + // This prevents the IllegalArgumentException that states 'restricted header name: ...' + if (IGNORE_HEADERS.contains(name.toLowerCase())) { + return; + } + builder.header(name, value); + }); if (req.getHeader("User-Agent") == null) { - builder = builder.header("User-Agent", AddSeleniumUserAgent.USER_AGENT); + builder.header("User-Agent", AddSeleniumUserAgent.USER_AGENT); } builder.timeout(config.readTimeout()); diff --git a/java/src/org/openqa/selenium/remote/http/netty/NettyDomainSocketClient.java b/java/src/org/openqa/selenium/remote/http/netty/NettyDomainSocketClient.java index f1f311f0b7724..8bceb93195b69 100644 --- a/java/src/org/openqa/selenium/remote/http/netty/NettyDomainSocketClient.java +++ b/java/src/org/openqa/selenium/remote/http/netty/NettyDomainSocketClient.java @@ -136,9 +136,7 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException { HttpMethod.valueOf(req.getMethod().toString()), uri.toString(), Unpooled.wrappedBuffer(bytes)); - req.getHeaderNames() - .forEach( - name -> req.getHeaders(name).forEach(value -> fullRequest.headers().add(name, value))); + req.forEachHeader(fullRequest.headers()::add); if (req.getHeader("User-Agent") == null) { fullRequest.headers().set("User-Agent", AddSeleniumUserAgent.USER_AGENT); } diff --git a/java/src/org/openqa/selenium/remote/http/netty/NettyMessages.java b/java/src/org/openqa/selenium/remote/http/netty/NettyMessages.java index a70e96256822d..14af46f076171 100644 --- a/java/src/org/openqa/selenium/remote/http/netty/NettyMessages.java +++ b/java/src/org/openqa/selenium/remote/http/netty/NettyMessages.java @@ -69,11 +69,7 @@ protected static Request toNettyRequest(ClientConfig config, HttpRequest request request.removeHeader("Content-Length"); } - for (String name : request.getHeaderNames()) { - for (String value : request.getHeaders(name)) { - builder.addHeader(name, value); - } - } + request.forEachHeader(builder::addHeader); if (request.getHeader("User-Agent") == null) { builder.addHeader("User-Agent", AddSeleniumUserAgent.USER_AGENT); } diff --git a/java/test/org/openqa/selenium/netty/server/NettyServerTest.java b/java/test/org/openqa/selenium/netty/server/NettyServerTest.java index 9533804a2c7d2..04ba014a5be17 100644 --- a/java/test/org/openqa/selenium/netty/server/NettyServerTest.java +++ b/java/test/org/openqa/selenium/netty/server/NettyServerTest.java @@ -142,10 +142,6 @@ void shouldNotBindToHost() { } private void outputHeaders(HttpResponse res) { - res.getHeaderNames() - .forEach( - name -> - res.getHeaders(name) - .forEach(value -> System.out.printf("%s -> %s\n", name, value))); + res.forEachHeader((name, value) -> System.out.printf("%s -> %s\n", name, value)); } } From 0d0eb4a04254a7fb45b60601855972020fb239ae Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Thu, 31 Aug 2023 15:56:17 -0400 Subject: [PATCH 003/141] [dotnet] Be more defensive when shutting down BiDi WebSocket --- .../src/webdriver/DevTools/DevToolsSession.cs | 17 ++--------------- .../webdriver/DevTools/WebSocketConnection.cs | 4 ++++ .../test/common/DevTools/DevToolsTestFixture.cs | 1 + 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/dotnet/src/webdriver/DevTools/DevToolsSession.cs b/dotnet/src/webdriver/DevTools/DevToolsSession.cs index 33d98824665c7..45adc7551f1ab 100644 --- a/dotnet/src/webdriver/DevTools/DevToolsSession.cs +++ b/dotnet/src/webdriver/DevTools/DevToolsSession.cs @@ -55,8 +55,6 @@ public class DevToolsSession : IDevToolsSession private DevToolsDomains domains; - private readonly SemaphoreSlim semaphoreSlimForSocketSend = new SemaphoreSlim(1, 1); - /// /// Initializes a new instance of the DevToolsSession class, using the specified WebSocket endpoint. /// @@ -219,18 +217,7 @@ public T GetVersionSpecificDomains() where T : DevToolsSessionDomains string contents = JsonConvert.SerializeObject(message); this.pendingCommands.TryAdd(message.CommandId, message); - - // socket SendAsync cannot be ran simultaneously, waiting available single worker - await semaphoreSlimForSocketSend.WaitAsync(cancellationToken); - - try - { - await this.connection.SendData(contents); - } - finally - { - semaphoreSlimForSocketSend.Release(); - } + await this.connection.SendData(contents); var responseWasReceived = await Task.Run(() => message.SyncEvent.Wait(millisecondsTimeout.Value, cancellationToken)); @@ -335,7 +322,7 @@ protected void Dispose(bool disposing) { this.Domains.Target.TargetDetached -= this.OnTargetDetached; this.pendingCommands.Clear(); - this.TerminateSocketConnection().GetAwaiter().GetResult(); + Task.Run(async () => await this.TerminateSocketConnection()).GetAwaiter().GetResult(); } this.isDisposed = true; diff --git a/dotnet/src/webdriver/DevTools/WebSocketConnection.cs b/dotnet/src/webdriver/DevTools/WebSocketConnection.cs index 939a334f931ee..e7ed53c78a4de 100644 --- a/dotnet/src/webdriver/DevTools/WebSocketConnection.cs +++ b/dotnet/src/webdriver/DevTools/WebSocketConnection.cs @@ -186,6 +186,10 @@ protected virtual async Task CloseClientWebSocket() { // An OperationCanceledException is normal upon task/token cancellation, so disregard it } + catch (WebSocketException e) + { + this.Log($"Unexpected error during attempt at close: {e.Message}", DevToolsSessionLogLevel.Error); + } } /// diff --git a/dotnet/test/common/DevTools/DevToolsTestFixture.cs b/dotnet/test/common/DevTools/DevToolsTestFixture.cs index c676b4ab21bd5..fa7e0d1a4355c 100644 --- a/dotnet/test/common/DevTools/DevToolsTestFixture.cs +++ b/dotnet/test/common/DevTools/DevToolsTestFixture.cs @@ -39,6 +39,7 @@ public void Teardown() { session.Dispose(); EnvironmentManager.Instance.CloseCurrentDriver(); + session = null; driver = null; } } From cf986e05ad1f30cf2d36c00c8d7688c3cc105007 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Thu, 31 Aug 2023 15:18:58 -0500 Subject: [PATCH 004/141] [rb] update lock file --- rb/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rb/Gemfile.lock b/rb/Gemfile.lock index b8438b50c28c2..7e037739fa23a 100644 --- a/rb/Gemfile.lock +++ b/rb/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - selenium-devtools (0.115.0) + selenium-devtools (0.116.0) selenium-webdriver (~> 4.2) selenium-webdriver (4.12.0) rexml (~> 3.2, >= 3.2.5) From 89ef913af172a2edf3888b700e05ba25e6f06865 Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Thu, 31 Aug 2023 16:43:00 -0400 Subject: [PATCH 005/141] [dotnet] Remove incorrect screenshot color comparisons for Chrome --- dotnet/test/common/TakesScreenshotTest.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dotnet/test/common/TakesScreenshotTest.cs b/dotnet/test/common/TakesScreenshotTest.cs index f4407f7445e28..4024ee153ddc3 100644 --- a/dotnet/test/common/TakesScreenshotTest.cs +++ b/dotnet/test/common/TakesScreenshotTest.cs @@ -67,6 +67,8 @@ public void GetScreenshotAsBinary() [Test] [IgnoreBrowser(Browser.IE, "Color comparisons fail on IE")] + [IgnoreBrowser(Browser.Chrome, "Color comparisons fail on Chrome")] + [IgnoreBrowser(Browser.Edge, "Color comparisons fail on Edge")] public void ShouldCaptureScreenshotOfCurrentViewport() { #if NET6_0 @@ -95,6 +97,8 @@ public void ShouldCaptureScreenshotOfCurrentViewport() } [Test] + [IgnoreBrowser(Browser.Chrome, "Color comparisons fail on Chrome")] + [IgnoreBrowser(Browser.Edge, "Color comparisons fail on Edge")] public void ShouldTakeScreenshotsOfAnElement() { #if NET6_0 @@ -122,6 +126,8 @@ public void ShouldTakeScreenshotsOfAnElement() [Test] [IgnoreBrowser(Browser.IE, "Color comparisons fail on IE")] + [IgnoreBrowser(Browser.Chrome, "Color comparisons fail on Chrome")] + [IgnoreBrowser(Browser.Edge, "Color comparisons fail on Edge")] public void ShouldCaptureScreenshotAtFramePage() { #if NET6_0 @@ -165,6 +171,8 @@ public void ShouldCaptureScreenshotAtFramePage() [Test] [IgnoreBrowser(Browser.IE, "Color comparisons fail on IE")] + [IgnoreBrowser(Browser.Chrome, "Color comparisons fail on Chrome")] + [IgnoreBrowser(Browser.Edge, "Color comparisons fail on Edge")] public void ShouldCaptureScreenshotAtIFramePage() { #if NET6_0 @@ -206,6 +214,8 @@ public void ShouldCaptureScreenshotAtIFramePage() [Test] [IgnoreBrowser(Browser.IE, "Color comparisons fail on IE")] [IgnoreBrowser(Browser.Firefox, "Color comparisons fail on Firefox")] + [IgnoreBrowser(Browser.Chrome, "Color comparisons fail on Chrome")] + [IgnoreBrowser(Browser.Edge, "Color comparisons fail on Edge")] public void ShouldCaptureScreenshotAtFramePageAfterSwitching() { #if NET6_0 @@ -245,6 +255,8 @@ public void ShouldCaptureScreenshotAtFramePageAfterSwitching() [Test] [IgnoreBrowser(Browser.IE, "Color comparisons fail on IE")] [IgnoreBrowser(Browser.Firefox, "Color comparisons fail on Firefox")] + [IgnoreBrowser(Browser.Chrome, "Color comparisons fail on Chrome")] + [IgnoreBrowser(Browser.Edge, "Color comparisons fail on Edge")] public void ShouldCaptureScreenshotAtIFramePageAfterSwitching() { #if NET6_0 From 4273c4b3ee76faa8c80e6cb103ff0410e5a65ef7 Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Thu, 31 Aug 2023 16:51:42 -0400 Subject: [PATCH 006/141] [dotnet] Build test assemblies to correct platform targets --- dotnet/test/common/BUILD.bazel | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dotnet/test/common/BUILD.bazel b/dotnet/test/common/BUILD.bazel index f3961b08c4d65..39d5c2ce24800 100644 --- a/dotnet/test/common/BUILD.bazel +++ b/dotnet/test/common/BUILD.bazel @@ -58,9 +58,9 @@ config_setting( "requires-network", ], target_frameworks = select({ - ":netframework": ["net471"], - ":netcore": ["netcoreapp3.1"], - "//conditions:default": ["netcoreapp3.1"], + ":netframework": ["net48"], + ":netcore": ["net6.0"] + "//conditions:default": ["net6.0"], }), visibility = ["//visibility:public"], deps = select({ From 23cca5e83bbe27c6303fcb78c22ade8467999739 Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Thu, 31 Aug 2023 16:53:53 -0400 Subject: [PATCH 007/141] [dotnet] Move disposal of ClientWebSocket to correct location --- dotnet/src/webdriver/DevTools/WebSocketConnection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dotnet/src/webdriver/DevTools/WebSocketConnection.cs b/dotnet/src/webdriver/DevTools/WebSocketConnection.cs index e7ed53c78a4de..5d21b0d24d8bd 100644 --- a/dotnet/src/webdriver/DevTools/WebSocketConnection.cs +++ b/dotnet/src/webdriver/DevTools/WebSocketConnection.cs @@ -146,6 +146,8 @@ public virtual async Task Stop() { await this.dataReceiveTask; } + + this.client.Dispose(); } /// @@ -268,7 +270,6 @@ private async Task ReceiveData() } finally { - this.client.Dispose(); this.isActive = false; } } From 09f5b157e15fe0c62e40a0a37fc76252ce1025d1 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Thu, 31 Aug 2023 15:57:59 -0500 Subject: [PATCH 008/141] [dotnet] only do releases for netstandard 2.0 --- dotnet/private/nuget.bzl | 3 +-- dotnet/selenium-dotnet-version.bzl | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dotnet/private/nuget.bzl b/dotnet/private/nuget.bzl index 15128ad41d9ab..a746c3ccbd73f 100644 --- a/dotnet/private/nuget.bzl +++ b/dotnet/private/nuget.bzl @@ -2,7 +2,6 @@ load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load("//dotnet/private:copy_files.bzl", "copy_files") load( "//dotnet:selenium-dotnet-version.bzl", - "SUPPORTED_NET_FRAMEWORKS", "SUPPORTED_NET_STANDARD_VERSIONS", ) @@ -60,7 +59,7 @@ def _get_relative_destination_file(src_file): src_file_dirs = src_file.dirname.split("/") framework_dir = src_file_dirs[-1] for src_file_dir in reversed(src_file_dirs): - if src_file_dir in SUPPORTED_NET_FRAMEWORKS or src_file_dir in SUPPORTED_NET_STANDARD_VERSIONS: + if src_file_dir in src_file_dir in SUPPORTED_NET_STANDARD_VERSIONS: framework_dir = src_file_dir break return "{}/{}".format(framework_dir, src_file.basename) diff --git a/dotnet/selenium-dotnet-version.bzl b/dotnet/selenium-dotnet-version.bzl index bafad9c1852c1..e819d71770eae 100644 --- a/dotnet/selenium-dotnet-version.bzl +++ b/dotnet/selenium-dotnet-version.bzl @@ -2,8 +2,7 @@ SE_VERSION = "4.12.0" ASSEMBLY_VERSION = "4.0.0.0" -SUPPORTED_NET_FRAMEWORKS = ["net45", "net46", "net47", "net48"] -SUPPORTED_NET_STANDARD_VERSIONS = ["netstandard2.0", "netstandard2.1", "net5.0", "net6.0"] +SUPPORTED_NET_STANDARD_VERSIONS = ["netstandard2.0"] SUPPORTED_DEVTOOLS_VERSIONS = [ "v85", From 799b84c2b11c0a59dff603ffde95ed60b09f4ee6 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Thu, 31 Aug 2023 16:02:59 -0500 Subject: [PATCH 009/141] [dotnet] update changelog and version for 4.12.1 --- dotnet/CHANGELOG | 5 +++++ dotnet/selenium-dotnet-version.bzl | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dotnet/CHANGELOG b/dotnet/CHANGELOG index c268051e8b757..bcd6a854c2c46 100644 --- a/dotnet/CHANGELOG +++ b/dotnet/CHANGELOG @@ -1,3 +1,8 @@ +v4.12.1 +====== +* Only target Netstandard 2.0 for release +* Fix bug for disposal of ClientWebSocket + v4.12.0 ====== * Add CDP files for v116 and remove v113 diff --git a/dotnet/selenium-dotnet-version.bzl b/dotnet/selenium-dotnet-version.bzl index e819d71770eae..8328a9c1cf6bc 100644 --- a/dotnet/selenium-dotnet-version.bzl +++ b/dotnet/selenium-dotnet-version.bzl @@ -1,6 +1,6 @@ # BUILD FILE SYNTAX: STARLARK -SE_VERSION = "4.12.0" +SE_VERSION = "4.12.1" ASSEMBLY_VERSION = "4.0.0.0" SUPPORTED_NET_STANDARD_VERSIONS = ["netstandard2.0"] From 7fbeda0013a57376c8d88b9814539929fe6d3287 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Thu, 31 Aug 2023 16:06:29 -0500 Subject: [PATCH 010/141] [dotnet] fix the logic for removing SUPPORTED_NET_FRAMEWORKS --- dotnet/private/nuget.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/private/nuget.bzl b/dotnet/private/nuget.bzl index a746c3ccbd73f..cbabe3ea8d168 100644 --- a/dotnet/private/nuget.bzl +++ b/dotnet/private/nuget.bzl @@ -59,7 +59,7 @@ def _get_relative_destination_file(src_file): src_file_dirs = src_file.dirname.split("/") framework_dir = src_file_dirs[-1] for src_file_dir in reversed(src_file_dirs): - if src_file_dir in src_file_dir in SUPPORTED_NET_STANDARD_VERSIONS: + if src_file_dir in SUPPORTED_NET_STANDARD_VERSIONS: framework_dir = src_file_dir break return "{}/{}".format(framework_dir, src_file.basename) From c2f96ec324f7aee9c153933a04c66d053a1f8abf Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Thu, 31 Aug 2023 17:07:20 -0400 Subject: [PATCH 011/141] [dotnet] Add additional assert in DevToolsNetworkTest --- dotnet/test/common/DevTools/DevToolsNetworkTest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dotnet/test/common/DevTools/DevToolsNetworkTest.cs b/dotnet/test/common/DevTools/DevToolsNetworkTest.cs index 3860873d11117..a1139ec04a934 100644 --- a/dotnet/test/common/DevTools/DevToolsNetworkTest.cs +++ b/dotnet/test/common/DevTools/DevToolsNetworkTest.cs @@ -390,7 +390,8 @@ public async Task VerifyRequestPostData() driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("postForm.html"); driver.FindElement(By.XPath("//form/input")).Click(); - requestSync.Wait(TimeSpan.FromSeconds(5)); + bool requestEventFired = requestSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(requestEventFired, Is.True); var response = await domains.Network.GetRequestPostData(new CurrentCdpVersion.Network.GetRequestPostDataCommandSettings() { From 35b746796fa4369542384a4a50f37f51fa13fdb7 Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Thu, 31 Aug 2023 17:13:59 -0400 Subject: [PATCH 012/141] [dotnet] Adding more asserts that events have fired for DevToolsNetworkTests --- .../common/DevTools/DevToolsNetworkTest.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/dotnet/test/common/DevTools/DevToolsNetworkTest.cs b/dotnet/test/common/DevTools/DevToolsNetworkTest.cs index a1139ec04a934..206e7b7028f65 100644 --- a/dotnet/test/common/DevTools/DevToolsNetworkTest.cs +++ b/dotnet/test/common/DevTools/DevToolsNetworkTest.cs @@ -108,9 +108,9 @@ await domains.Network.SetExtraHTTPHeaders(new CurrentCdpVersion.Network.SetExtra domains.Network.DataReceived += dataReceivedHandler; driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("js/skins/lightgray/content.min.css"); - loadingFailedSync.Wait(TimeSpan.FromSeconds(5)); - requestSentSync.Wait(TimeSpan.FromSeconds(5)); - dataSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(loadingFailedSync.Wait(TimeSpan.FromSeconds(5)), Is.True); + Assert.That(requestSentSync.Wait(TimeSpan.FromSeconds(5)), Is.True); + Assert.That(dataSync.Wait(TimeSpan.FromSeconds(5)), Is.True); } [Test] @@ -151,7 +151,7 @@ await domains.Network.EmulateNetworkConditions(new CurrentCdpVersion.Network.Emu Assert.That(e.Message.Contains("net::ERR_INTERNET_DISCONNECTED")); } - loadingFailedSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(loadingFailedSync.Wait(TimeSpan.FromSeconds(5)), Is.True); } [Test] @@ -188,8 +188,8 @@ await domains.Network.Enable(new CurrentCdpVersion.Network.EnableCommandSettings driver.Url = simpleTestPage; driver.Url = simpleTestPage; - loadingFinishedSync.Wait(TimeSpan.FromSeconds(5)); - servedFromCacheSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(loadingFinishedSync.Wait(TimeSpan.FromSeconds(5)), Is.True); + Assert.That(servedFromCacheSync.Wait(TimeSpan.FromSeconds(5)), Is.True); var responseBody = await domains.Network.GetResponseBody(new CurrentCdpVersion.Network.GetResponseBodyCommandSettings() { @@ -224,7 +224,7 @@ await domains.Network.Enable(new CurrentCdpVersion.Network.EnableCommandSettings domains.Network.ResponseReceived += responseReceivedHandler; driver.Url = simpleTestPage; - responseSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(responseSync.Wait(TimeSpan.FromSeconds(5)), Is.True); var searchResponse = await domains.Network.SearchInResponseBody(new CurrentCdpVersion.Network.SearchInResponseBodyCommandSettings() { @@ -256,7 +256,7 @@ await domains.Network.Enable(new CurrentCdpVersion.Network.EnableCommandSettings domains.Network.ResponseReceived += responseReceivedHandler; driver.Url = simpleTestPage; - responseSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(responseSync.Wait(TimeSpan.FromSeconds(5)), Is.True); await domains.Network.SetCacheDisabled(new CurrentCdpVersion.Network.SetCacheDisabledCommandSettings() { @@ -292,7 +292,7 @@ await domains.Network.SetUserAgentOverride(new CurrentCdpVersion.Network.SetUser string origin = EnvironmentManager.Instance.UrlBuilder.WhereIsSecure("simpleTest.html"); driver.Url = origin; - requestSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(requestSync.Wait(TimeSpan.FromSeconds(5)), Is.True); var result = await domains.Network.GetCertificate(new CurrentCdpVersion.Network.GetCertificateCommandSettings() { @@ -319,7 +319,7 @@ public async Task VerifyResponseReceivedEventAndNetworkDisable() domains.Network.ResponseReceived += responseReceivedHandler; driver.Url = simpleTestPage; - responseSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(responseSync.Wait(TimeSpan.FromSeconds(5)), Is.True); await domains.Network.Disable(); } @@ -433,7 +433,7 @@ public async Task VerifyEventSourceMessage() domains.Network.EventSourceMessageReceived += eventSourceMessageReceivedHandler; driver.Url = simpleTestPage; - requestSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(requestSync.Wait(TimeSpan.FromSeconds(5)), Is.True); } [Test] @@ -455,7 +455,7 @@ public async Task VerifySignedExchangeReceived() domains.Network.SignedExchangeReceived += signedExchangeReceivedHandler; driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIsSecure("simpleTest.html"); - requestSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(requestSync.Wait(TimeSpan.FromSeconds(5)), Is.True); } [Test] @@ -476,7 +476,7 @@ public async Task VerifyResourceChangedPriority() domains.Network.ResourceChangedPriority += resourceChangedPriorityHandler; driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("simpleTest.html"); - requestSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(requestSync.Wait(TimeSpan.FromSeconds(5)), Is.True); } [Test] @@ -512,7 +512,7 @@ await domains.Network.SetRequestInterception(new CurrentCdpVersion.Network.SetRe }); driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("js/skins/lightgray/content.min.css"); - requestSync.Wait(TimeSpan.FromSeconds(5)); + Assert.That(requestSync.Wait(TimeSpan.FromSeconds(5)), Is.True); } } } From 26300325752e01c3803d471a13c558fb80dea691 Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Thu, 31 Aug 2023 18:36:16 -0400 Subject: [PATCH 013/141] [dotnet] Fix Bazel build file in test directory --- dotnet/test/common/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/test/common/BUILD.bazel b/dotnet/test/common/BUILD.bazel index 39d5c2ce24800..0569614a8ed4d 100644 --- a/dotnet/test/common/BUILD.bazel +++ b/dotnet/test/common/BUILD.bazel @@ -59,7 +59,7 @@ config_setting( ], target_frameworks = select({ ":netframework": ["net48"], - ":netcore": ["net6.0"] + ":netcore": ["net6.0"], "//conditions:default": ["net6.0"], }), visibility = ["//visibility:public"], From bb1faafc5e1492d8cd7ebfc9bb1343acc377cf61 Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Thu, 31 Aug 2023 18:58:28 -0400 Subject: [PATCH 014/141] [dotnet] Fix build break in tests --- dotnet/test/common/SessionHandlingTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dotnet/test/common/SessionHandlingTest.cs b/dotnet/test/common/SessionHandlingTest.cs index 5947c35bc34ae..da652fe1d94d2 100644 --- a/dotnet/test/common/SessionHandlingTest.cs +++ b/dotnet/test/common/SessionHandlingTest.cs @@ -46,7 +46,7 @@ public void CallingAnyOperationAfterClosingTheLastWindowShouldThrowAnException() string url = string.Empty; testDriver.Url = simpleTestPage; testDriver.Close(); - Assert.That(() => url = testDriver.Url, Throws.InstanceOf().Or.InstanceOf(), "Should not be able to access Url property after close of only open window"); + Assert.That(() => testDriver.Url == formsPage, Throws.InstanceOf().Or.InstanceOf()); } finally { @@ -65,7 +65,7 @@ public void CallingAnyOperationAfterQuitShouldThrowAnException() string url = string.Empty; testDriver.Url = simpleTestPage; testDriver.Quit(); - Assert.That(() => url = testDriver.Url, Throws.InstanceOf().Or.InstanceOf(), "Should not be able to access Url property after close of only open window"); + Assert.That(() => testDriver.Url == formsPage, Throws.InstanceOf().Or.InstanceOf()); } finally { From 11f67c1b88d74f4ce961d14b1252b8c653ec158c Mon Sep 17 00:00:00 2001 From: Selenium CI Bot Date: Fri, 1 Sep 2023 00:15:52 +0000 Subject: [PATCH 015/141] Update mirror info (Fri Sep 1 00:15:52 UTC 2023) --- common/mirror/selenium | 49 ++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/common/mirror/selenium b/common/mirror/selenium index e2da4e2630639..2d0a6e9eb94cd 100644 --- a/common/mirror/selenium +++ b/common/mirror/selenium @@ -1,4 +1,30 @@ [ + { + "tag_name": "selenium-4.12.0", + "assets": [ + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-4.12.0.zip" + }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-4.12.1.zip" + }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-strongnamed-4.12.0.zip" + }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-strongnamed-4.12.1.zip" + }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-java-4.12.0.zip" + }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-server-4.12.0.jar" + }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-server-4.12.0.zip" + } + ] + }, { "tag_name": "nightly", "assets": [ @@ -854,28 +880,5 @@ "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.59/selenium-server-standalone-3.141.59.jar" } ] - }, - { - "tag_name": "selenium-3.141.5", - "assets": [ - { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.5/IEDriverServer_Win32_3.141.5.zip" - }, - { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.5/IEDriverServer_x64_3.141.5.zip" - }, - { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.5/selenium-html-runner-3.141.5.jar" - }, - { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.5/selenium-java-3.141.5.zip" - }, - { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.5/selenium-server-3.141.5.zip" - }, - { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.5/selenium-server-standalone-3.141.5.jar" - } - ] } ] From ff9590375ce20a1d412bddb1ba6603f68e5badb2 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Thu, 31 Aug 2023 22:21:08 -0500 Subject: [PATCH 016/141] [dotnet] bump to 4.12.2 to fix a release issue with 4.12.1 --- dotnet/CHANGELOG | 4 ++++ dotnet/selenium-dotnet-version.bzl | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dotnet/CHANGELOG b/dotnet/CHANGELOG index bcd6a854c2c46..bb50c1bc61515 100644 --- a/dotnet/CHANGELOG +++ b/dotnet/CHANGELOG @@ -1,3 +1,7 @@ +v4.12.2 +====== +* No code changes; issue with 4.12.1 release + v4.12.1 ====== * Only target Netstandard 2.0 for release diff --git a/dotnet/selenium-dotnet-version.bzl b/dotnet/selenium-dotnet-version.bzl index 8328a9c1cf6bc..6fdf2d50751ec 100644 --- a/dotnet/selenium-dotnet-version.bzl +++ b/dotnet/selenium-dotnet-version.bzl @@ -1,6 +1,6 @@ # BUILD FILE SYNTAX: STARLARK -SE_VERSION = "4.12.1" +SE_VERSION = "4.12.2" ASSEMBLY_VERSION = "4.0.0.0" SUPPORTED_NET_STANDARD_VERSIONS = ["netstandard2.0"] From a2cc4c9ccba23fd95afbc6c9e81deb1f48838375 Mon Sep 17 00:00:00 2001 From: Selenium CI Bot Date: Fri, 1 Sep 2023 12:06:21 +0000 Subject: [PATCH 017/141] Update mirror info (Fri Sep 1 12:06:21 UTC 2023) --- common/mirror/selenium | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/mirror/selenium b/common/mirror/selenium index 2d0a6e9eb94cd..f9bddad236336 100644 --- a/common/mirror/selenium +++ b/common/mirror/selenium @@ -8,12 +8,18 @@ { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-4.12.1.zip" }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-4.12.2.zip" + }, { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-strongnamed-4.12.0.zip" }, { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-strongnamed-4.12.1.zip" }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-strongnamed-4.12.2.zip" + }, { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-java-4.12.0.zip" }, From 57503a531ce9492e3aa6b137f376ac5dee63ec3a Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 1 Sep 2023 16:30:10 +0300 Subject: [PATCH 018/141] [dotnet] Fix saving png screenshot as file (#12654) Fix saving png screenshot as file --- dotnet/src/webdriver/Screenshot.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dotnet/src/webdriver/Screenshot.cs b/dotnet/src/webdriver/Screenshot.cs index 8b53f9da2919d..5a29d77e6f89a 100644 --- a/dotnet/src/webdriver/Screenshot.cs +++ b/dotnet/src/webdriver/Screenshot.cs @@ -103,10 +103,12 @@ public void SaveAsFile(string fileName, ScreenshotImageFormat format) { imageStream.WriteTo(fileStream); } - - using (Image screenshotImage = Image.FromStream(imageStream)) + else { - screenshotImage.Save(fileStream, ConvertScreenshotImageFormat(format)); + using (Image screenshotImage = Image.FromStream(imageStream)) + { + screenshotImage.Save(fileStream, ConvertScreenshotImageFormat(format)); + } } } } From cef99fc4be71fe72a98e3713b02a418832ff9df1 Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Fri, 1 Sep 2023 13:24:02 -0400 Subject: [PATCH 019/141] [dotnet] Correcting failures in CDP Network event tests --- .../common/DevTools/DevToolsNetworkTest.cs | 58 +++---------------- 1 file changed, 9 insertions(+), 49 deletions(-) diff --git a/dotnet/test/common/DevTools/DevToolsNetworkTest.cs b/dotnet/test/common/DevTools/DevToolsNetworkTest.cs index 206e7b7028f65..f7211c14c8087 100644 --- a/dotnet/test/common/DevTools/DevToolsNetworkTest.cs +++ b/dotnet/test/common/DevTools/DevToolsNetworkTest.cs @@ -68,7 +68,7 @@ public async Task SendRequestWithUrlFiltersAndExtraHeadersAndVerifyRequests() await domains.Network.Enable(new CurrentCdpVersion.Network.EnableCommandSettings()); await domains.Network.SetBlockedURLs(new CurrentCdpVersion.Network.SetBlockedURLsCommandSettings() { - Urls = new string[] { "*://*/*.css" } + Urls = new string[] { "*://*/*.gif" } }); var additionalHeaders = new CurrentCdpVersion.Network.Headers(); @@ -81,7 +81,7 @@ await domains.Network.SetExtraHTTPHeaders(new CurrentCdpVersion.Network.SetExtra ManualResetEventSlim loadingFailedSync = new ManualResetEventSlim(false); EventHandler loadingFailedHandler = (sender, e) => { - if (e.Type == CurrentCdpVersion.Network.ResourceType.Stylesheet) + if (e.Type == CurrentCdpVersion.Network.ResourceType.Image) { Assert.That(e.BlockedReason == CurrentCdpVersion.Network.BlockedReason.Inspector); } @@ -93,9 +93,12 @@ await domains.Network.SetExtraHTTPHeaders(new CurrentCdpVersion.Network.SetExtra ManualResetEventSlim requestSentSync = new ManualResetEventSlim(false); EventHandler requestWillBeSentHandler = (sender, e) => { - Assert.That(e.Request.Headers.ContainsKey("headerName")); - Assert.That(e.Request.Headers["headerName"] == "headerValue"); - requestSentSync.Set(); + if (e.Type != CurrentCdpVersion.Network.ResourceType.Image) + { + Assert.That(e.Request.Headers.ContainsKey("headerName")); + Assert.That(e.Request.Headers["headerName"] == "headerValue"); + requestSentSync.Set(); + } }; domains.Network.RequestWillBeSent += requestWillBeSentHandler; @@ -107,7 +110,7 @@ await domains.Network.SetExtraHTTPHeaders(new CurrentCdpVersion.Network.SetExtra }; domains.Network.DataReceived += dataReceivedHandler; - driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("js/skins/lightgray/content.min.css"); + driver.Url = linkedImage; Assert.That(loadingFailedSync.Wait(TimeSpan.FromSeconds(5)), Is.True); Assert.That(requestSentSync.Wait(TimeSpan.FromSeconds(5)), Is.True); Assert.That(dataSync.Wait(TimeSpan.FromSeconds(5)), Is.True); @@ -415,27 +418,6 @@ await domains.Network.SetBypassServiceWorker(new CurrentCdpVersion.Network.SetBy }); } - [Test] - [IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")] - [IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Chrome DevTools Protocol")] - [IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")] - public async Task VerifyEventSourceMessage() - { - var domains = session.GetVersionSpecificDomains(); - await domains.Network.Enable(new CurrentCdpVersion.Network.EnableCommandSettings()); - - ManualResetEventSlim requestSync = new ManualResetEventSlim(false); - EventHandler eventSourceMessageReceivedHandler = (sender, e) => - { - Assert.That(e, Is.Not.Null); - requestSync.Set(); - }; - domains.Network.EventSourceMessageReceived += eventSourceMessageReceivedHandler; - - driver.Url = simpleTestPage; - Assert.That(requestSync.Wait(TimeSpan.FromSeconds(5)), Is.True); - } - [Test] [Ignore("Unable to open secure url")] [IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")] @@ -458,27 +440,6 @@ public async Task VerifySignedExchangeReceived() Assert.That(requestSync.Wait(TimeSpan.FromSeconds(5)), Is.True); } - [Test] - [IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")] - [IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Chrome DevTools Protocol")] - [IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")] - public async Task VerifyResourceChangedPriority() - { - var domains = session.GetVersionSpecificDomains(); - await domains.Network.Enable(new CurrentCdpVersion.Network.EnableCommandSettings()); - - ManualResetEventSlim requestSync = new ManualResetEventSlim(false); - EventHandler resourceChangedPriorityHandler = (sender, e) => - { - Assert.That(e, Is.Not.Null); - requestSync.Set(); - }; - domains.Network.ResourceChangedPriority += resourceChangedPriorityHandler; - - driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("simpleTest.html"); - Assert.That(requestSync.Wait(TimeSpan.FromSeconds(5)), Is.True); - } - [Test] [IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")] [IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Chrome DevTools Protocol")] @@ -502,7 +463,6 @@ await domains.Network.ContinueInterceptedRequest(new CurrentCdpVersion.Network.C var pattern = new CurrentCdpVersion.Network.RequestPattern() { UrlPattern = "*.css", - ResourceType = CurrentCdpVersion.Network.ResourceType.Stylesheet, InterceptionStage = CurrentCdpVersion.Network.InterceptionStage.HeadersReceived }; From d670a703a3ff9d896bb9eeb0c0d8254d9371acb9 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 2 Sep 2023 02:15:22 +0300 Subject: [PATCH 020/141] [dotnet] Close dev tools session safely (#12660) --- dotnet/src/webdriver/Chromium/ChromiumDriver.cs | 2 +- dotnet/src/webdriver/Firefox/FirefoxDriver.cs | 2 +- dotnet/src/webdriver/Remote/RemoteWebDriver.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dotnet/src/webdriver/Chromium/ChromiumDriver.cs b/dotnet/src/webdriver/Chromium/ChromiumDriver.cs index a27d4fa9eb25b..38b09ca3e998f 100644 --- a/dotnet/src/webdriver/Chromium/ChromiumDriver.cs +++ b/dotnet/src/webdriver/Chromium/ChromiumDriver.cs @@ -323,7 +323,7 @@ public void CloseDevToolsSession() { if (this.devToolsSession != null) { - this.devToolsSession.StopSession(true).ConfigureAwait(false).GetAwaiter().GetResult(); + Task.Run(async () => await this.devToolsSession.StopSession(true)).GetAwaiter().GetResult(); } } diff --git a/dotnet/src/webdriver/Firefox/FirefoxDriver.cs b/dotnet/src/webdriver/Firefox/FirefoxDriver.cs index 27312276dafe9..bc3b3827400ae 100644 --- a/dotnet/src/webdriver/Firefox/FirefoxDriver.cs +++ b/dotnet/src/webdriver/Firefox/FirefoxDriver.cs @@ -415,7 +415,7 @@ public void CloseDevToolsSession() { if (this.devToolsSession != null) { - this.devToolsSession.StopSession(true).ConfigureAwait(false).GetAwaiter().GetResult(); + Task.Run(async () => await this.devToolsSession.StopSession(true)).GetAwaiter().GetResult(); } } diff --git a/dotnet/src/webdriver/Remote/RemoteWebDriver.cs b/dotnet/src/webdriver/Remote/RemoteWebDriver.cs index 8205ff4ea14fc..73275ae52b81f 100644 --- a/dotnet/src/webdriver/Remote/RemoteWebDriver.cs +++ b/dotnet/src/webdriver/Remote/RemoteWebDriver.cs @@ -475,7 +475,7 @@ public void CloseDevToolsSession() { if (this.devToolsSession != null) { - this.devToolsSession.StopSession(true).ConfigureAwait(false).GetAwaiter().GetResult(); + Task.Run(async () => await this.devToolsSession.StopSession(true)).GetAwaiter().GetResult(); } } From 174e39490e71fba5e0a110eba76f23ae574355ee Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 2 Sep 2023 02:16:12 +0300 Subject: [PATCH 021/141] [dotnet] Send data over cdp consecutively (#12666) Send data over cdp consecutively --- .../src/webdriver/DevTools/WebSocketConnection.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dotnet/src/webdriver/DevTools/WebSocketConnection.cs b/dotnet/src/webdriver/DevTools/WebSocketConnection.cs index 5d21b0d24d8bd..7eb315c25e409 100644 --- a/dotnet/src/webdriver/DevTools/WebSocketConnection.cs +++ b/dotnet/src/webdriver/DevTools/WebSocketConnection.cs @@ -37,6 +37,7 @@ public class WebSocketConnection private Task dataReceiveTask; private bool isActive = false; private ClientWebSocket client = new ClientWebSocket(); + private readonly SemaphoreSlim sendMethodSemaphore = new SemaphoreSlim(1, 1); /// /// Initializes a new instance of the class. @@ -159,7 +160,17 @@ public virtual async Task SendData(string data) { ArraySegment messageBuffer = new ArraySegment(Encoding.UTF8.GetBytes(data)); this.Log($"SEND >>> {data}"); - await this.client.SendAsync(messageBuffer, WebSocketMessageType.Text, endOfMessage: true, CancellationToken.None); + + await sendMethodSemaphore.WaitAsync().ConfigureAwait(false); + + try + { + await this.client.SendAsync(messageBuffer, WebSocketMessageType.Text, endOfMessage: true, CancellationToken.None); + } + finally + { + sendMethodSemaphore.Release(); + } } /// From 22a9b2e46180b44d85e2532c9dc545631e4e794c Mon Sep 17 00:00:00 2001 From: Selenium CI Bot Date: Sat, 2 Sep 2023 12:05:45 +0000 Subject: [PATCH 022/141] Update mirror info (Sat Sep 2 12:05:45 UTC 2023) --- common/mirror/selenium | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/common/mirror/selenium b/common/mirror/selenium index f9bddad236336..3b8522f74749c 100644 --- a/common/mirror/selenium +++ b/common/mirror/selenium @@ -1,4 +1,18 @@ [ + { + "tag_name": "nightly", + "assets": [ + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-java-4.12.0-SNAPSHOT.zip" + }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.12.0-SNAPSHOT.jar" + }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.12.0-SNAPSHOT.zip" + } + ] + }, { "tag_name": "selenium-4.12.0", "assets": [ @@ -31,20 +45,6 @@ } ] }, - { - "tag_name": "nightly", - "assets": [ - { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-java-4.12.0-SNAPSHOT.zip" - }, - { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.12.0-SNAPSHOT.jar" - }, - { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.12.0-SNAPSHOT.zip" - } - ] - }, { "tag_name": "selenium-4.11.0", "assets": [ From 404462d48862bc15ab5c21b1ad2c4d227d083794 Mon Sep 17 00:00:00 2001 From: David English Date: Sat, 2 Sep 2023 10:39:48 -0400 Subject: [PATCH 023/141] [rb] Fix release date in changelog (#12668) Fix release date --- rb/CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rb/CHANGES b/rb/CHANGES index 4d60eb81edafa..f00cdb41eef27 100644 --- a/rb/CHANGES +++ b/rb/CHANGES @@ -1,4 +1,4 @@ -4.12.0 (Unreleased) +4.12.0 (2023-08-31) ========================= Ruby: * Fix bug preventing good error messages in Selenium Manager when stdout empty From cc41a883b5138962c6b4408a0fdf4e932bd08071 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sat, 2 Sep 2023 14:20:45 -0500 Subject: [PATCH 024/141] [java] safari driver service system properties should be public --- java/src/org/openqa/selenium/safari/SafariDriverService.java | 2 +- .../openqa/selenium/safari/SafariTechPreviewDriverService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java/src/org/openqa/selenium/safari/SafariDriverService.java b/java/src/org/openqa/selenium/safari/SafariDriverService.java index a79c4e8f24f72..b06ab082cfa65 100644 --- a/java/src/org/openqa/selenium/safari/SafariDriverService.java +++ b/java/src/org/openqa/selenium/safari/SafariDriverService.java @@ -47,7 +47,7 @@ public class SafariDriverService extends DriverService { */ public static final String SAFARI_DRIVER_EXE_PROPERTY = "webdriver.safari.driver"; - private static final String SAFARI_DRIVER_LOGGING = "webdriver.safari.logging"; + public static final String SAFARI_DRIVER_LOGGING = "webdriver.safari.logging"; private static final File SAFARI_DRIVER_EXECUTABLE = new File("/usr/bin/safaridriver"); diff --git a/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java b/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java index 0c674d11bcfe4..c14336b3852ee 100644 --- a/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java +++ b/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java @@ -47,7 +47,7 @@ public class SafariTechPreviewDriverService extends DriverService { */ public static final String TP_SAFARI_DRIVER_EXE_PROPERTY = "webdriver.tp.safari.driver"; - private static final String TP_SAFARI_DRIVER_LOGGING = "webdriver.tp.safari.logging"; + public static final String TP_SAFARI_DRIVER_LOGGING = "webdriver.tp.safari.logging"; private static final File TP_SAFARI_DRIVER_EXECUTABLE = new File("/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver"); From 0178bb1e045b44d61e09489f7d7f06283e35513e Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 4 Sep 2023 10:58:58 +0200 Subject: [PATCH 025/141] [grid] Removing browserVersion before sending payload to driver Fixes #12663 --- .../config/DriverServiceSessionFactory.java | 34 ++++++++++++------- .../selenium/manager/SeleniumManager.java | 7 ++-- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java b/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java index e7e3e267c0db8..309731b36090e 100644 --- a/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java +++ b/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java @@ -127,11 +127,6 @@ public Either apply(CreateSessionRequest sess Capabilities capabilities = sessionCapabilitiesMutator.apply(sessionRequest.getDesiredCapabilities()); - Optional platformName = Optional.ofNullable(capabilities.getPlatformName()); - if (platformName.isPresent()) { - capabilities = removePlatform(capabilities); - } - CAPABILITIES.accept(span, capabilities); CAPABILITIES_EVENT.accept(attributeMap, capabilities); attributeMap.put( @@ -145,6 +140,17 @@ public Either apply(CreateSessionRequest sess capabilities = setBrowserBinary(capabilities, result.getBrowserPath()); } } + + Optional platformName = Optional.ofNullable(capabilities.getPlatformName()); + if (platformName.isPresent()) { + capabilities = removeCapability(capabilities, "platformName"); + } + + Optional browserVersion = Optional.ofNullable(capabilities.getBrowserVersion()); + if (browserVersion.isPresent()) { + capabilities = removeCapability(capabilities, "browserVersion"); + } + try { service.start(); @@ -179,7 +185,10 @@ public Either apply(CreateSessionRequest sess Capabilities caps = new ImmutableCapabilities((Map) response.getValue()); if (platformName.isPresent()) { - caps = setInitialPlatform(caps, platformName.get()); + caps = setInitialCapabilityValue(caps, "platformName", platformName.get()); + } + if (browserVersion.isPresent()) { + caps = setInitialCapabilityValue(caps, "browserVersion", browserVersion.get()); } caps = readDevToolsEndpointAndVersion(caps); @@ -319,16 +328,17 @@ private Capabilities readVncEndpoint(Capabilities requestedCaps, Capabilities re return returnedCaps; } - // We remove the platform before sending the caps to the driver because some drivers will - // reject session requests when they cannot parse the platform. - private Capabilities removePlatform(Capabilities caps) { + // We remove a capability before sending the caps to the driver because some drivers will + // reject session requests when they cannot parse the specific capabilities (like platform or + // browser version). + private Capabilities removeCapability(Capabilities caps, String capability) { MutableCapabilities noPlatformName = new MutableCapabilities(new HashMap<>(caps.asMap())); - noPlatformName.setCapability("platformName", (String) null); + noPlatformName.setCapability(capability, (String) null); return new PersistentCapabilities(noPlatformName); } - private Capabilities setInitialPlatform(Capabilities caps, Platform platform) { - return new PersistentCapabilities(caps).setCapability("platformName", platform); + private Capabilities setInitialCapabilityValue(Capabilities caps, String key, Object value) { + return new PersistentCapabilities(caps).setCapability(key, value); } private String getHost() { diff --git a/java/src/org/openqa/selenium/manager/SeleniumManager.java b/java/src/org/openqa/selenium/manager/SeleniumManager.java index 382350d7f7bea..a3dbf666cf9dd 100644 --- a/java/src/org/openqa/selenium/manager/SeleniumManager.java +++ b/java/src/org/openqa/selenium/manager/SeleniumManager.java @@ -31,7 +31,6 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; import org.openqa.selenium.Beta; @@ -258,7 +257,11 @@ public Result getDriverPath(Capabilities options, boolean offline) { if (!options.getBrowserVersion().isEmpty()) { arguments.add("--browser-version"); arguments.add(options.getBrowserVersion()); - ((MutableCapabilities) options).setCapability("browserVersion", Optional.empty()); + // We know the browser binary path, we don't need the browserVersion. + // Useful when "beta" is specified as browserVersion, but the browser driver cannot match it. + if (options instanceof MutableCapabilities) { + ((MutableCapabilities) options).setCapability("browserVersion", (String) null); + } } String browserBinary = getBrowserBinary(options); From c8814aeb2c50a28a74df45b731461aeaee8d98ac Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Mon, 4 Sep 2023 13:52:47 +0300 Subject: [PATCH 026/141] [dotnet] Show output from selenium manager error stream (#12677) Show output from selenium manager error stream Co-authored-by: Diego Molina --- dotnet/src/webdriver/SeleniumManager.cs | 32 ++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/dotnet/src/webdriver/SeleniumManager.cs b/dotnet/src/webdriver/SeleniumManager.cs index 457443316d248..070f0b1e71d71 100644 --- a/dotnet/src/webdriver/SeleniumManager.cs +++ b/dotnet/src/webdriver/SeleniumManager.cs @@ -92,9 +92,12 @@ public static string DriverPath(DriverOptions options) if (options.Proxy != null) { - if (options.Proxy.SslProxy != null) { + if (options.Proxy.SslProxy != null) + { argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --proxy \"{0}\"", options.Proxy.SslProxy); - } else if (options.Proxy.HttpProxy != null) { + } + else if (options.Proxy.HttpProxy != null) + { argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --proxy \"{0}\"", options.Proxy.HttpProxy); } } @@ -137,16 +140,20 @@ private static Dictionary RunCommand(string fileName, string arg process.StartInfo.RedirectStandardError = true; StringBuilder outputBuilder = new StringBuilder(); + StringBuilder errorOutputBuilder = new StringBuilder(); DataReceivedEventHandler outputHandler = (sender, e) => outputBuilder.AppendLine(e.Data); + DataReceivedEventHandler errorOutputHandler = (sender, e) => errorOutputBuilder.AppendLine(e.Data); try { process.OutputDataReceived += outputHandler; + process.ErrorDataReceived += errorOutputHandler; process.Start(); process.BeginOutputReadLine(); + process.BeginErrorReadLine(); process.WaitForExit(); @@ -154,7 +161,25 @@ private static Dictionary RunCommand(string fileName, string arg { // We do not log any warnings coming from Selenium Manager like the other bindings as we don't have any logging in the .NET bindings - throw new WebDriverException($"Selenium Manager process exited abnormally with {process.ExitCode} code: {fileName} {arguments}\n{outputBuilder}"); + var exceptionMessageBuilder = new StringBuilder($"Selenium Manager process exited abnormally with {process.ExitCode} code: {fileName} {arguments}"); + + if (!string.IsNullOrEmpty(errorOutputBuilder.ToString())) + { + exceptionMessageBuilder.AppendLine(); + exceptionMessageBuilder.Append("Error Output >>"); + exceptionMessageBuilder.AppendLine(); + exceptionMessageBuilder.Append(errorOutputBuilder); + } + + if (!string.IsNullOrEmpty(outputBuilder.ToString())) + { + exceptionMessageBuilder.AppendLine(); + exceptionMessageBuilder.Append("Standard Output >>"); + exceptionMessageBuilder.AppendLine(); + exceptionMessageBuilder.Append(outputBuilder); + } + + throw new WebDriverException(exceptionMessageBuilder.ToString()); } } catch (Exception ex) @@ -164,6 +189,7 @@ private static Dictionary RunCommand(string fileName, string arg finally { process.OutputDataReceived -= outputHandler; + process.ErrorDataReceived -= errorOutputHandler; } string output = outputBuilder.ToString().Trim(); From be6d2884001dee8c001adc808c610bd1e084b5f7 Mon Sep 17 00:00:00 2001 From: Titus Fortner Date: Mon, 4 Sep 2023 06:24:34 -0500 Subject: [PATCH 027/141] [java] Selenium Manager don't log file paths by default (#12673) [java] Selenium Manager does not log location of browser and driver by default Co-authored-by: Diego Molina --- java/src/org/openqa/selenium/manager/SeleniumManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/manager/SeleniumManager.java b/java/src/org/openqa/selenium/manager/SeleniumManager.java index a3dbf666cf9dd..033363610e102 100644 --- a/java/src/org/openqa/selenium/manager/SeleniumManager.java +++ b/java/src/org/openqa/selenium/manager/SeleniumManager.java @@ -127,7 +127,10 @@ private static Result runCommand(Path binary, List arguments) { if (!output.isEmpty()) { try { jsonOutput = new Json().toType(output, SeleniumManagerOutput.class); - jsonOutput.getLogs().forEach(logged -> LOG.log(logged.getLevel(), logged.getMessage())); + jsonOutput.getLogs().forEach(logged -> { + Level currentLevel = logged.getLevel() == Level.INFO ? Level.FINE : logged.getLevel(); + LOG.log(currentLevel, logged.getMessage()); + }); dump = jsonOutput.getResult().getMessage(); } catch (JsonException e) { failedToParse = e; From f6645361145ead3972a0e855c13002eb28c9fecc Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Mon, 4 Sep 2023 16:58:57 +0300 Subject: [PATCH 028/141] [dotnet] Return Task instead of wait it in generated CDP method invocations (#12672) Return Task instead of wait it in generated CDP method invocations Co-authored-by: Diego Molina --- .../dotnet/devtools/src/generator/Templates/domain.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/dotnet/devtools/src/generator/Templates/domain.hbs b/third_party/dotnet/devtools/src/generator/Templates/domain.hbs index 2eb033990c404..b7b46a2540645 100644 --- a/third_party/dotnet/devtools/src/generator/Templates/domain.hbs +++ b/third_party/dotnet/devtools/src/generator/Templates/domain.hbs @@ -46,9 +46,9 @@ namespace {{rootNamespace}}.{{domain.Name}} /// /// {{xml-code-comment Description 2}} /// - public async Task<{{dehumanize Name}}CommandResponse> {{dehumanize Name}}({{dehumanize Name}}CommandSettings command{{#if NoParameters}} = null{{/if}}, CancellationToken cancellationToken = default(CancellationToken), int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true) + public Task<{{dehumanize Name}}CommandResponse> {{dehumanize Name}}({{dehumanize Name}}CommandSettings command{{#if NoParameters}} = null{{/if}}, CancellationToken cancellationToken = default(CancellationToken), int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true) { - return await m_session.SendCommand<{{dehumanize Name}}CommandSettings, {{dehumanize Name}}CommandResponse>(command{{#if NoParameters}} ?? new {{dehumanize Name}}CommandSettings(){{/if}}, cancellationToken, millisecondsTimeout, throwExceptionIfResponseNotReceived); + return m_session.SendCommand<{{dehumanize Name}}CommandSettings, {{dehumanize Name}}CommandResponse>(command{{#if NoParameters}} ?? new {{dehumanize Name}}CommandSettings(){{/if}}, cancellationToken, millisecondsTimeout, throwExceptionIfResponseNotReceived); } {{/each}} From a6173b0f6ee5cfe9c5d2eac3d2c952bfac7e0969 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Mon, 4 Sep 2023 18:28:34 +0300 Subject: [PATCH 029/141] [dotnet] Invoke console log api called event many times depending on count of args (#12669) Invoke console log api called event many times depending on count of arguments Co-authored-by: Diego Molina --- dotnet/src/webdriver/JavaScriptEngine.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dotnet/src/webdriver/JavaScriptEngine.cs b/dotnet/src/webdriver/JavaScriptEngine.cs index b3828234f1052..6570b259ca4ea 100644 --- a/dotnet/src/webdriver/JavaScriptEngine.cs +++ b/dotnet/src/webdriver/JavaScriptEngine.cs @@ -415,12 +415,15 @@ private void OnConsoleApiCalled(object sender, ConsoleApiCalledEventArgs e) { if (this.JavaScriptConsoleApiCalled != null) { - this.JavaScriptConsoleApiCalled(this, new JavaScriptConsoleApiCalledEventArgs() + for (int i = 0; i < e.Arguments.Count; i++) { - MessageContent = e.Arguments[0].Value, - MessageTimeStamp = e.Timestamp, - MessageType = e.Type - }); + this.JavaScriptConsoleApiCalled(this, new JavaScriptConsoleApiCalledEventArgs() + { + MessageContent = e.Arguments[i].Value, + MessageTimeStamp = e.Timestamp, + MessageType = e.Type + }); + } } } } From 839a598c69cc335f15bf20e7a1cd834982b02c7e Mon Sep 17 00:00:00 2001 From: Titus Fortner Date: Mon, 4 Sep 2023 11:28:10 -0500 Subject: [PATCH 030/141] [java] parse log output to support streams and file location in system properties (#12674) Co-authored-by: Diego Molina --- .../selenium/chrome/ChromeDriverService.java | 26 ++++----- .../selenium/edge/EdgeDriverService.java | 29 +++++----- .../selenium/firefox/GeckoDriverService.java | 5 +- .../ie/InternetExplorerDriverService.java | 14 ++--- .../remote/service/DriverService.java | 54 +++++++++---------- .../selenium/safari/SafariDriverService.java | 5 +- .../SafariTechPreviewDriverService.java | 5 +- 7 files changed, 61 insertions(+), 77 deletions(-) diff --git a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java index 4490db98eb662..78c7763e2ab2c 100644 --- a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java +++ b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java @@ -29,6 +29,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + +import com.google.common.io.ByteStreams; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.chromium.ChromiumDriverLogLevel; @@ -287,12 +289,7 @@ public Builder withReadableTimestamp(Boolean readableTimestamp) { @Override protected void loadSystemProperties() { - if (getLogFile() == null) { - String logFilePath = System.getProperty(CHROME_DRIVER_LOG_PROPERTY); - if (logFilePath != null) { - withLogFile(new File(logFilePath)); - } - } + parseLogOutput(CHROME_DRIVER_LOG_PROPERTY); if (disableBuildCheck == null) { this.disableBuildCheck = Boolean.getBoolean(CHROME_DRIVER_DISABLE_BUILD_CHECK); } @@ -322,17 +319,17 @@ protected List createArgs() { List args = new ArrayList<>(); args.add(String.format("--port=%d", getPort())); - // Readable timestamp and append logs only work if a file is specified - // Can only get readable logs via arguments; otherwise send service output as directed + // Readable timestamp and append logs only work if log path is specified in args + // Cannot use logOutput because goog:loggingPrefs requires --log-path get sent if (getLogFile() != null) { args.add(String.format("--log-path=%s", getLogFile().getAbsolutePath())); - if (readableTimestamp != null && readableTimestamp.equals(Boolean.TRUE)) { + if (Boolean.TRUE.equals(readableTimestamp)) { args.add("--readable-timestamp"); } - if (appendLog != null && appendLog.equals(Boolean.TRUE)) { + if (Boolean.TRUE.equals(appendLog)) { args.add("--append-log"); } - withLogFile(null); // Do not overwrite in sendOutputTo() + withLogOutput(ByteStreams.nullOutputStream()); // Do not overwrite log file in getLogOutput() } if (logLevel != null) { @@ -341,7 +338,7 @@ protected List createArgs() { if (allowedListIps != null) { args.add(String.format("--allowed-ips=%s", allowedListIps)); } - if (disableBuildCheck != null && disableBuildCheck.equals(Boolean.TRUE)) { + if (Boolean.TRUE.equals(disableBuildCheck)) { args.add("--disable-build-check"); } @@ -352,10 +349,7 @@ protected List createArgs() { protected ChromeDriverService createDriverService( File exe, int port, Duration timeout, List args, Map environment) { try { - ChromeDriverService service = - new ChromeDriverService(exe, port, timeout, args, environment); - service.sendOutputTo(getLogOutput(CHROME_DRIVER_LOG_PROPERTY)); - return service; + return new ChromeDriverService(exe, port, timeout, args, environment); } catch (IOException e) { throw new WebDriverException(e); } diff --git a/java/src/org/openqa/selenium/edge/EdgeDriverService.java b/java/src/org/openqa/selenium/edge/EdgeDriverService.java index 601a22afb2be9..ea5742faf6c5b 100644 --- a/java/src/org/openqa/selenium/edge/EdgeDriverService.java +++ b/java/src/org/openqa/selenium/edge/EdgeDriverService.java @@ -30,6 +30,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + +import com.google.common.io.ByteStreams; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.chromium.ChromiumDriverLogLevel; @@ -255,12 +257,7 @@ public Builder withReadableTimestamp(Boolean readableTimestamp) { @Override protected void loadSystemProperties() { - if (getLogFile() == null) { - String logFilePath = System.getProperty(EDGE_DRIVER_LOG_PROPERTY); - if (logFilePath != null) { - withLogFile(new File(logFilePath)); - } - } + parseLogOutput(EDGE_DRIVER_LOG_PROPERTY); if (disableBuildCheck == null) { this.disableBuildCheck = Boolean.getBoolean(EDGE_DRIVER_DISABLE_BUILD_CHECK); } @@ -290,32 +287,32 @@ protected List createArgs() { List args = new ArrayList<>(); args.add(String.format("--port=%d", getPort())); - // Readable timestamp and append logs only work if a file is specified - // Can only get readable logs via arguments; otherwise send service output as directed + // Readable timestamp and append logs only work if log path is specified in args + // Cannot use logOutput because goog:loggingPrefs requires --log-path get sent if (getLogFile() != null) { args.add(String.format("--log-path=%s", getLogFile().getAbsolutePath())); - if (readableTimestamp != null && readableTimestamp.equals(Boolean.TRUE)) { + if (Boolean.TRUE.equals(readableTimestamp)) { args.add("--readable-timestamp"); } - if (appendLog != null && appendLog.equals(Boolean.TRUE)) { + if (Boolean.TRUE.equals(appendLog)) { args.add("--append-log"); } - withLogFile(null); // Do not overwrite in sendOutputTo() + withLogOutput(ByteStreams.nullOutputStream()); // Do not overwrite log file in getLogOutput() } if (logLevel != null) { args.add(String.format("--log-level=%s", logLevel.toString().toUpperCase())); } - if (silent != null && silent.equals(Boolean.TRUE)) { + if (Boolean.TRUE.equals(silent)) { args.add("--silent"); } - if (verbose != null && verbose.equals(Boolean.TRUE)) { + if (Boolean.TRUE.equals(verbose)) { args.add("--verbose"); } if (allowedListIps != null) { args.add(String.format("--allowed-ips=%s", allowedListIps)); } - if (disableBuildCheck != null && disableBuildCheck.equals(Boolean.TRUE)) { + if (Boolean.TRUE.equals(disableBuildCheck)) { args.add("--disable-build-check"); } @@ -326,9 +323,7 @@ protected List createArgs() { protected EdgeDriverService createDriverService( File exe, int port, Duration timeout, List args, Map environment) { try { - EdgeDriverService service = new EdgeDriverService(exe, port, timeout, args, environment); - service.sendOutputTo(getLogOutput(EDGE_DRIVER_LOG_PROPERTY)); - return service; + return new EdgeDriverService(exe, port, timeout, args, environment); } catch (IOException e) { throw new WebDriverException(e); } diff --git a/java/src/org/openqa/selenium/firefox/GeckoDriverService.java b/java/src/org/openqa/selenium/firefox/GeckoDriverService.java index 0022be7c992b8..99378a3ef434e 100644 --- a/java/src/org/openqa/selenium/firefox/GeckoDriverService.java +++ b/java/src/org/openqa/selenium/firefox/GeckoDriverService.java @@ -245,6 +245,7 @@ public GeckoDriverService.Builder withProfileRoot(File root) { @Override protected void loadSystemProperties() { + parseLogOutput(GECKO_DRIVER_LOG_PROPERTY); if (logLevel == null) { String logFilePath = System.getProperty(GECKO_DRIVER_LOG_LEVEL_PROPERTY); if (logFilePath != null) { @@ -304,9 +305,7 @@ protected List createArgs() { protected GeckoDriverService createDriverService( File exe, int port, Duration timeout, List args, Map environment) { try { - GeckoDriverService service = new GeckoDriverService(exe, port, timeout, args, environment); - service.sendOutputTo(getLogOutput(GECKO_DRIVER_LOG_PROPERTY)); - return service; + return new GeckoDriverService(exe, port, timeout, args, environment); } catch (IOException e) { throw new WebDriverException(e); } diff --git a/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java b/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java index 555122530db3a..b69a0f4977111 100644 --- a/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java +++ b/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java @@ -187,12 +187,7 @@ public Builder withSilent(Boolean silent) { @Override protected void loadSystemProperties() { - if (getLogFile() == null) { - String logFilePath = System.getProperty(IE_DRIVER_LOGFILE_PROPERTY); - if (logFilePath != null) { - withLogFile(new File(logFilePath)); - } - } + parseLogOutput(IE_DRIVER_LOGFILE_PROPERTY); if (logLevel == null) { String level = System.getProperty(IE_DRIVER_LOGLEVEL_PROPERTY); if (level != null) { @@ -233,7 +228,7 @@ protected List createArgs() { if (extractPath != null) { args.add(String.format("--extract-path=\"%s\"", extractPath.getAbsolutePath())); } - if (silent != null && silent.equals(Boolean.TRUE)) { + if (Boolean.TRUE.equals(silent)) { args.add("--silent"); } @@ -244,10 +239,7 @@ protected List createArgs() { protected InternetExplorerDriverService createDriverService( File exe, int port, Duration timeout, List args, Map environment) { try { - InternetExplorerDriverService service = - new InternetExplorerDriverService(exe, port, timeout, args, environment); - service.sendOutputTo(getLogOutput(IE_DRIVER_LOGFILE_PROPERTY)); - return service; + return new InternetExplorerDriverService(exe, port, timeout, args, environment); } catch (IOException e) { throw new WebDriverException(e); } diff --git a/java/src/org/openqa/selenium/remote/service/DriverService.java b/java/src/org/openqa/selenium/remote/service/DriverService.java index f10c3dd71c0dc..138619a2c4879 100644 --- a/java/src/org/openqa/selenium/remote/service/DriverService.java +++ b/java/src/org/openqa/selenium/remote/service/DriverService.java @@ -437,40 +437,36 @@ protected Duration getDefaultTimeout() { return DEFAULT_TIMEOUT; } - protected OutputStream getLogOutput(String logProperty) { - if (logOutputStream != null) { - return logOutputStream; - } - + protected OutputStream getLogOutput() { try { - File logFileLocation = getLogFile(); - String logLocation; - - if (logFileLocation == null) { - logLocation = System.getProperty(logProperty); - } else { - logLocation = logFileLocation.getAbsolutePath(); - } - - if (logLocation == null) { - return ByteStreams.nullOutputStream(); - } - - switch (logLocation) { - case LOG_STDOUT: - return System.out; - case LOG_STDERR: - return System.err; - case LOG_NULL: - return ByteStreams.nullOutputStream(); - default: - return new FileOutputStream(logLocation); - } + return logOutputStream != null ? logOutputStream : new FileOutputStream(logFile); } catch (FileNotFoundException e) { throw new RuntimeException(e); } } + protected void parseLogOutput(String logProperty) { + if (getLogFile() != null) { + return; + } + + String logLocation = System.getProperty(logProperty, LOG_NULL); + switch (logLocation) { + case LOG_STDOUT: + withLogOutput(System.out); + break; + case LOG_STDERR: + withLogOutput(System.err); + break; + case LOG_NULL: + withLogOutput(ByteStreams.nullOutputStream()); + break; + default: + withLogFile(new File(logLocation)); + break; + } + } + /** * Creates a new service to manage the driver server. Before creating a new service, the builder * will find a port for the server to listen to. @@ -490,6 +486,8 @@ public DS build() { List args = createArgs(); DS service = createDriverService(exe, port, timeout, args, environment); + service.sendOutputTo(getLogOutput()); + port = 0; // reset port to allow reusing this builder return service; diff --git a/java/src/org/openqa/selenium/safari/SafariDriverService.java b/java/src/org/openqa/selenium/safari/SafariDriverService.java index b06ab082cfa65..26367c77ae4f1 100644 --- a/java/src/org/openqa/selenium/safari/SafariDriverService.java +++ b/java/src/org/openqa/selenium/safari/SafariDriverService.java @@ -31,6 +31,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + +import com.google.common.io.ByteStreams; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.net.PortProber; @@ -168,7 +170,7 @@ protected void loadSystemProperties() { @Override protected List createArgs() { List args = new ArrayList<>(Arrays.asList("--port", String.valueOf(getPort()))); - if (diagnose != null && diagnose.equals(Boolean.TRUE)) { + if (Boolean.TRUE.equals(diagnose)) { args.add("--diagnose"); } return args; @@ -178,6 +180,7 @@ protected List createArgs() { protected SafariDriverService createDriverService( File exe, int port, Duration timeout, List args, Map environment) { try { + withLogOutput(ByteStreams.nullOutputStream()); return new SafariDriverService(exe, port, timeout, args, environment); } catch (IOException e) { throw new WebDriverException(e); diff --git a/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java b/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java index c14336b3852ee..55b483c39d548 100644 --- a/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java +++ b/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java @@ -31,6 +31,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + +import com.google.common.io.ByteStreams; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.net.PortProber; @@ -172,7 +174,7 @@ protected void loadSystemProperties() { @Override protected List createArgs() { List args = new ArrayList<>(Arrays.asList("--port", String.valueOf(getPort()))); - if (this.diagnose) { + if (Boolean.TRUE.equals(diagnose)) { args.add("--diagnose"); } return args; @@ -182,6 +184,7 @@ protected List createArgs() { protected SafariTechPreviewDriverService createDriverService( File exe, int port, Duration timeout, List args, Map environment) { try { + withLogOutput(ByteStreams.nullOutputStream()); return new SafariTechPreviewDriverService(exe, port, timeout, args, environment); } catch (IOException e) { throw new WebDriverException(e); From 42889d7659e5709e119e4be079d35117233d4dca Mon Sep 17 00:00:00 2001 From: Simon Mavi Stewart Date: Mon, 4 Sep 2023 17:47:10 +0100 Subject: [PATCH 031/141] Run format.sh. No logical changes --- .../openqa/selenium/chrome/ChromeDriverService.java | 6 +++--- .../org/openqa/selenium/edge/EdgeDriverService.java | 6 +++--- .../org/openqa/selenium/manager/SeleniumManager.java | 12 ++++++++---- .../openqa/selenium/safari/SafariDriverService.java | 3 +-- .../safari/SafariTechPreviewDriverService.java | 3 +-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java index 78c7763e2ab2c..2e06bbc0d6757 100644 --- a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java +++ b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java @@ -22,6 +22,7 @@ import static org.openqa.selenium.remote.Browser.CHROME; import com.google.auto.service.AutoService; +import com.google.common.io.ByteStreams; import java.io.File; import java.io.IOException; import java.time.Duration; @@ -29,8 +30,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - -import com.google.common.io.ByteStreams; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.chromium.ChromiumDriverLogLevel; @@ -329,7 +328,8 @@ protected List createArgs() { if (Boolean.TRUE.equals(appendLog)) { args.add("--append-log"); } - withLogOutput(ByteStreams.nullOutputStream()); // Do not overwrite log file in getLogOutput() + withLogOutput( + ByteStreams.nullOutputStream()); // Do not overwrite log file in getLogOutput() } if (logLevel != null) { diff --git a/java/src/org/openqa/selenium/edge/EdgeDriverService.java b/java/src/org/openqa/selenium/edge/EdgeDriverService.java index ea5742faf6c5b..030f4c1e8e340 100644 --- a/java/src/org/openqa/selenium/edge/EdgeDriverService.java +++ b/java/src/org/openqa/selenium/edge/EdgeDriverService.java @@ -23,6 +23,7 @@ import static org.openqa.selenium.remote.Browser.EDGE; import com.google.auto.service.AutoService; +import com.google.common.io.ByteStreams; import java.io.File; import java.io.IOException; import java.time.Duration; @@ -30,8 +31,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - -import com.google.common.io.ByteStreams; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.chromium.ChromiumDriverLogLevel; @@ -297,7 +296,8 @@ protected List createArgs() { if (Boolean.TRUE.equals(appendLog)) { args.add("--append-log"); } - withLogOutput(ByteStreams.nullOutputStream()); // Do not overwrite log file in getLogOutput() + withLogOutput( + ByteStreams.nullOutputStream()); // Do not overwrite log file in getLogOutput() } if (logLevel != null) { diff --git a/java/src/org/openqa/selenium/manager/SeleniumManager.java b/java/src/org/openqa/selenium/manager/SeleniumManager.java index 033363610e102..563cfccd76764 100644 --- a/java/src/org/openqa/selenium/manager/SeleniumManager.java +++ b/java/src/org/openqa/selenium/manager/SeleniumManager.java @@ -127,10 +127,14 @@ private static Result runCommand(Path binary, List arguments) { if (!output.isEmpty()) { try { jsonOutput = new Json().toType(output, SeleniumManagerOutput.class); - jsonOutput.getLogs().forEach(logged -> { - Level currentLevel = logged.getLevel() == Level.INFO ? Level.FINE : logged.getLevel(); - LOG.log(currentLevel, logged.getMessage()); - }); + jsonOutput + .getLogs() + .forEach( + logged -> { + Level currentLevel = + logged.getLevel() == Level.INFO ? Level.FINE : logged.getLevel(); + LOG.log(currentLevel, logged.getMessage()); + }); dump = jsonOutput.getResult().getMessage(); } catch (JsonException e) { failedToParse = e; diff --git a/java/src/org/openqa/selenium/safari/SafariDriverService.java b/java/src/org/openqa/selenium/safari/SafariDriverService.java index 26367c77ae4f1..e6829f07a1603 100644 --- a/java/src/org/openqa/selenium/safari/SafariDriverService.java +++ b/java/src/org/openqa/selenium/safari/SafariDriverService.java @@ -23,6 +23,7 @@ import static org.openqa.selenium.remote.Browser.SAFARI; import com.google.auto.service.AutoService; +import com.google.common.io.ByteStreams; import java.io.File; import java.io.IOException; import java.time.Duration; @@ -31,8 +32,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - -import com.google.common.io.ByteStreams; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.net.PortProber; diff --git a/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java b/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java index 55b483c39d548..c3ef72a1d6cfd 100644 --- a/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java +++ b/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java @@ -23,6 +23,7 @@ import static org.openqa.selenium.remote.Browser.SAFARI_TECH_PREVIEW; import com.google.auto.service.AutoService; +import com.google.common.io.ByteStreams; import java.io.File; import java.io.IOException; import java.time.Duration; @@ -31,8 +32,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - -import com.google.common.io.ByteStreams; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.net.PortProber; From 8a1f5daf8cec394d6b483151bd17002d018b1e8e Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 4 Sep 2023 19:03:00 +0200 Subject: [PATCH 032/141] [grid] Correcting fix for #12663 --- .../selenium/grid/node/config/DriverServiceSessionFactory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java b/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java index 309731b36090e..09e6a6831d493 100644 --- a/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java +++ b/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java @@ -187,7 +187,8 @@ public Either apply(CreateSessionRequest sess if (platformName.isPresent()) { caps = setInitialCapabilityValue(caps, "platformName", platformName.get()); } - if (browserVersion.isPresent()) { + + if (caps.getBrowserVersion().isEmpty() && browserVersion.isPresent() && !browserVersion.get().isEmpty()) { caps = setInitialCapabilityValue(caps, "browserVersion", browserVersion.get()); } From 5bce8d952c5e18454dc9face3e7e3489075adeab Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 4 Sep 2023 19:04:00 +0200 Subject: [PATCH 033/141] [Java] Fixes #12682 --- .../org/openqa/selenium/remote/service/DriverService.java | 6 ++++++ .../selenium/safari/SafariTechPreviewDriverService.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/remote/service/DriverService.java b/java/src/org/openqa/selenium/remote/service/DriverService.java index 138619a2c4879..43dc4c2edc0d9 100644 --- a/java/src/org/openqa/selenium/remote/service/DriverService.java +++ b/java/src/org/openqa/selenium/remote/service/DriverService.java @@ -194,6 +194,12 @@ public void start() throws IOException { if (process != null) { return; } + if (this.executable == null) { + if (getDefaultDriverOptions().getBrowserName().isEmpty()) { + throw new WebDriverException("Driver executable is null and browser name is not set."); + } + this.executable = DriverFinder.getPath(this, getDefaultDriverOptions()).getDriverPath(); + } LOG.fine(String.format("Starting driver at %s with %s", this.executable, this.args)); process = new CommandLine(this.executable, args.toArray(new String[] {})); process.setEnvironmentVariables(environment); diff --git a/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java b/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java index c3ef72a1d6cfd..6eb0e3e9e35cb 100644 --- a/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java +++ b/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java @@ -105,7 +105,7 @@ public File getDriverExecutable() { } @Override - protected Capabilities getDefaultDriverOptions() { + public Capabilities getDefaultDriverOptions() { return new SafariOptions().setUseTechnologyPreview(true); } From 191623489c49daef1638ba44b7534631f685621f Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 4 Sep 2023 20:18:03 +0200 Subject: [PATCH 034/141] [java] Running format script --- .../grid/node/config/DriverServiceSessionFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java b/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java index 09e6a6831d493..3e41aaecce458 100644 --- a/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java +++ b/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java @@ -188,7 +188,9 @@ public Either apply(CreateSessionRequest sess caps = setInitialCapabilityValue(caps, "platformName", platformName.get()); } - if (caps.getBrowserVersion().isEmpty() && browserVersion.isPresent() && !browserVersion.get().isEmpty()) { + if (caps.getBrowserVersion().isEmpty() + && browserVersion.isPresent() + && !browserVersion.get().isEmpty()) { caps = setInitialCapabilityValue(caps, "browserVersion", browserVersion.get()); } From dfa68e5b001d4b0c53c199d85af758a679b18a83 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 4 Sep 2023 20:50:29 +0200 Subject: [PATCH 035/141] [dotnet] Bumping to 4.12.3 and CHANGELOG update --- dotnet/CHANGELOG | 10 ++++++++++ dotnet/selenium-dotnet-version.bzl | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dotnet/CHANGELOG b/dotnet/CHANGELOG index bb50c1bc61515..9ba87b85f6b61 100644 --- a/dotnet/CHANGELOG +++ b/dotnet/CHANGELOG @@ -1,3 +1,13 @@ +v4.12.3 +====== +* Fix saving png screenshot as file (#12654) +* Correcting failures in CDP Network event tests +* Close dev tools session safely (#12660) +* Send data over cdp consecutively (#12666) +* Show output from selenium manager error stream (#12677) +* Return Task instead of wait it in generated CDP method invocations (#12672) +* Invoke console log api called event many times depending on count of args (#12669) + v4.12.2 ====== * No code changes; issue with 4.12.1 release diff --git a/dotnet/selenium-dotnet-version.bzl b/dotnet/selenium-dotnet-version.bzl index 6fdf2d50751ec..0e668f9620cf4 100644 --- a/dotnet/selenium-dotnet-version.bzl +++ b/dotnet/selenium-dotnet-version.bzl @@ -1,6 +1,6 @@ # BUILD FILE SYNTAX: STARLARK -SE_VERSION = "4.12.2" +SE_VERSION = "4.12.3" ASSEMBLY_VERSION = "4.0.0.0" SUPPORTED_NET_STANDARD_VERSIONS = ["netstandard2.0"] From 8e34639b11a7d0f513a202736da387357bfd30a0 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 4 Sep 2023 21:37:08 +0200 Subject: [PATCH 036/141] [java] Bumping version to 4.12.1 --- Rakefile | 2 +- java/CHANGELOG | 9 +++++++++ java/version.bzl | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index cede1c68beb07..0d396b9d0c725 100644 --- a/Rakefile +++ b/Rakefile @@ -55,7 +55,7 @@ def release_version end def version - "#{release_version}.0-SNAPSHOT" + "#{release_version}.1" end # The build system used by webdriver is layered on top of rake, and we call it diff --git a/java/CHANGELOG b/java/CHANGELOG index 98eb0f411dba4..e02b4b905bbb0 100644 --- a/java/CHANGELOG +++ b/java/CHANGELOG @@ -1,3 +1,12 @@ +v4.12.1 +====== +* Supported CDP versions: 85, 114, 115, 116 +* Safari driver service system properties should be public +* [grid] Removing browserVersion before sending payload to driver +* Selenium Manager don't log file paths by default (#12673) +* Parse log output to support streams and file location in system properties (#12674) +* Fixing default service for drivers #12682 + v4.12.0 ====== * Supported CDP versions: 85, 114, 115, 116 diff --git a/java/version.bzl b/java/version.bzl index 96842492538d6..996eb0c4b58b5 100644 --- a/java/version.bzl +++ b/java/version.bzl @@ -1,2 +1,2 @@ -SE_VERSION = "4.12.0" +SE_VERSION = "4.12.1" TOOLS_JAVA_VERSION = "17" From 7d9f5b820d15c61bbe166482be221139bb12c596 Mon Sep 17 00:00:00 2001 From: Selenium CI Bot Date: Tue, 5 Sep 2023 00:14:26 +0000 Subject: [PATCH 037/141] Update mirror info (Tue Sep 5 00:14:26 UTC 2023) --- common/mirror/selenium | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/mirror/selenium b/common/mirror/selenium index 3b8522f74749c..34256fae8d41f 100644 --- a/common/mirror/selenium +++ b/common/mirror/selenium @@ -25,6 +25,9 @@ { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-4.12.2.zip" }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-4.12.3.zip" + }, { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-strongnamed-4.12.0.zip" }, @@ -34,14 +37,26 @@ { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-strongnamed-4.12.2.zip" }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-strongnamed-4.12.3.zip" + }, { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-java-4.12.0.zip" }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-java-4.12.1.zip" + }, { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-server-4.12.0.jar" }, { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-server-4.12.0.zip" + }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-server-4.12.1.jar" + }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-server-4.12.1.zip" } ] }, From 707dc0c560272de02893ca7df5ed36111329372d Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Tue, 5 Sep 2023 11:09:25 +0200 Subject: [PATCH 038/141] [dotnet] Bumping to 4.12.4 and CHANGELOG update --- dotnet/CHANGELOG | 4 ++++ dotnet/selenium-dotnet-version.bzl | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dotnet/CHANGELOG b/dotnet/CHANGELOG index 9ba87b85f6b61..c2d6abde626b6 100644 --- a/dotnet/CHANGELOG +++ b/dotnet/CHANGELOG @@ -1,3 +1,7 @@ +v4.12.4 +====== +* No code changes; issue with 4.12.3 release + v4.12.3 ====== * Fix saving png screenshot as file (#12654) diff --git a/dotnet/selenium-dotnet-version.bzl b/dotnet/selenium-dotnet-version.bzl index 0e668f9620cf4..018e60f7bae18 100644 --- a/dotnet/selenium-dotnet-version.bzl +++ b/dotnet/selenium-dotnet-version.bzl @@ -1,6 +1,6 @@ # BUILD FILE SYNTAX: STARLARK -SE_VERSION = "4.12.3" +SE_VERSION = "4.12.4" ASSEMBLY_VERSION = "4.0.0.0" SUPPORTED_NET_STANDARD_VERSIONS = ["netstandard2.0"] From 4a18e1d45060fceb8ed2e206ea90dfab4788c365 Mon Sep 17 00:00:00 2001 From: Selenium CI Bot Date: Tue, 5 Sep 2023 12:06:38 +0000 Subject: [PATCH 039/141] Update mirror info (Tue Sep 5 12:06:38 UTC 2023) --- common/mirror/selenium | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/common/mirror/selenium b/common/mirror/selenium index 34256fae8d41f..9e72d283f4081 100644 --- a/common/mirror/selenium +++ b/common/mirror/selenium @@ -3,13 +3,13 @@ "tag_name": "nightly", "assets": [ { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-java-4.12.0-SNAPSHOT.zip" + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-java-4.12.1.zip" }, { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.12.0-SNAPSHOT.jar" + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.12.1.jar" }, { - "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.12.0-SNAPSHOT.zip" + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.12.1.zip" } ] }, @@ -28,6 +28,9 @@ { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-4.12.3.zip" }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-4.12.4.zip" + }, { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-strongnamed-4.12.0.zip" }, @@ -40,6 +43,9 @@ { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-strongnamed-4.12.3.zip" }, + { + "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-dotnet-strongnamed-4.12.4.zip" + }, { "browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.12.0/selenium-java-4.12.0.zip" }, From 39abd4daab6a567c8a2c9b9afb547f74d91e879c Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Tue, 5 Sep 2023 21:59:24 +0200 Subject: [PATCH 040/141] [java] Marking some methods deprecated before deletion --- java/src/org/openqa/selenium/WebDriver.java | 2 +- java/src/org/openqa/selenium/remote/RemoteWebDriver.java | 1 + .../openqa/selenium/support/events/EventFiringWebDriver.java | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/WebDriver.java b/java/src/org/openqa/selenium/WebDriver.java index 9be57f91af7ca..843d4fc4247bf 100644 --- a/java/src/org/openqa/selenium/WebDriver.java +++ b/java/src/org/openqa/selenium/WebDriver.java @@ -346,7 +346,7 @@ default Duration getImplicitWaitTimeout() { } /** - * @deprecated Use {@link #setScriptTimeout(Duration)} + * @deprecated Use {@link #scriptTimeout(Duration)} *

Sets the amount of time to wait for an asynchronous script to finish execution before * throwing an error. If the timeout is negative, not null, or greater than 2e16 - 1, an * error code with invalid argument will be returned. diff --git a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java index a539750e09ad7..a648dc220f6ee 100644 --- a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java +++ b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java @@ -977,6 +977,7 @@ public Timeouts setScriptTimeout(long time, TimeUnit unit) { return setScriptTimeout(Duration.ofMillis(unit.toMillis(time))); } + @Deprecated @Override public Timeouts setScriptTimeout(Duration duration) { return scriptTimeout(duration); diff --git a/java/src/org/openqa/selenium/support/events/EventFiringWebDriver.java b/java/src/org/openqa/selenium/support/events/EventFiringWebDriver.java index 15edb37c36ea2..adc3477506f51 100644 --- a/java/src/org/openqa/selenium/support/events/EventFiringWebDriver.java +++ b/java/src/org/openqa/selenium/support/events/EventFiringWebDriver.java @@ -678,6 +678,7 @@ public Timeouts setScriptTimeout(long time, TimeUnit unit) { return setScriptTimeout(Duration.ofMillis(unit.toMillis(time))); } + @Deprecated @Override public Timeouts setScriptTimeout(Duration duration) { timeouts.setScriptTimeout(duration); From 09302f0fe510139ee89c94750fae7d0438b923e1 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Tue, 5 Sep 2023 22:00:47 +0200 Subject: [PATCH 041/141] [java] Removing deprecated move method at Point --- java/src/org/openqa/selenium/Point.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/java/src/org/openqa/selenium/Point.java b/java/src/org/openqa/selenium/Point.java index 1fb86dbf0ffdb..2488b41b708f8 100644 --- a/java/src/org/openqa/selenium/Point.java +++ b/java/src/org/openqa/selenium/Point.java @@ -56,15 +56,6 @@ public int hashCode() { return Objects.hash(x, y); } - /** - * @deprecated Use {{@link #moveBy(int, int)} instead} - */ - @Deprecated - public void move(int newX, int newY) { - x = newX; - y = newY; - } - @Override public String toString() { return String.format("(%d, %d)", x, y); From 3be8312c31e1796712aed0bd6de1ee10e4c70300 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Tue, 5 Sep 2023 22:04:20 +0200 Subject: [PATCH 042/141] [java] Removing deprecated 'usingFirefoxBinary', now use {@link FirefoxOptions#setBinary(Path)} --- .../selenium/firefox/GeckoDriverService.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/java/src/org/openqa/selenium/firefox/GeckoDriverService.java b/java/src/org/openqa/selenium/firefox/GeckoDriverService.java index 99378a3ef434e..ec61658612682 100644 --- a/java/src/org/openqa/selenium/firefox/GeckoDriverService.java +++ b/java/src/org/openqa/selenium/firefox/GeckoDriverService.java @@ -25,7 +25,6 @@ import com.google.auto.service.AutoService; import java.io.File; import java.io.IOException; -import java.nio.file.Path; import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; @@ -34,7 +33,6 @@ import java.util.Map; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.internal.Require; import org.openqa.selenium.net.PortProber; import org.openqa.selenium.remote.service.DriverService; @@ -188,20 +186,6 @@ public int score(Capabilities capabilities) { return score; } - /** - * Sets which browser executable the builder will use. - * - * @param firefoxBinary The browser executable to use. - * @return A self reference. - * @deprecated use {@link FirefoxOptions#setBinary(Path)} - */ - @Deprecated - public Builder usingFirefoxBinary(FirefoxBinary firefoxBinary) { - Require.nonNull("Firefox binary", firefoxBinary); - this.firefoxBinary = firefoxBinary; - return this; - } - /** * Values of the Host header to allow for incoming requests. * From 89bc39a60e8a1b2531f0f1d7da69105e998ae16e Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Tue, 5 Sep 2023 22:32:39 +0200 Subject: [PATCH 043/141] [java] Removing deprecated 'createDefaultService', now use {@link GeckoDriverService#createDefaultService()} --- .../openqa/selenium/firefox/GeckoDriverService.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/java/src/org/openqa/selenium/firefox/GeckoDriverService.java b/java/src/org/openqa/selenium/firefox/GeckoDriverService.java index ec61658612682..6796dcebdf906 100644 --- a/java/src/org/openqa/selenium/firefox/GeckoDriverService.java +++ b/java/src/org/openqa/selenium/firefox/GeckoDriverService.java @@ -139,16 +139,6 @@ public static GeckoDriverService createDefaultService() { return new Builder().build(); } - /** - * @param caps Capabilities instance - this is not used - * @return default GeckoDriverService - * @deprecated use {@link GeckoDriverService#createDefaultService()} - */ - @Deprecated - static GeckoDriverService createDefaultService(Capabilities caps) { - return createDefaultService(); - } - @Override protected void waitUntilAvailable() { PortProber.waitForPortUp(getUrl().getPort(), (int) getTimeout().toMillis(), MILLISECONDS); From d6085382e8b1cb772f6c186c2cd85423f3823bc2 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Tue, 5 Sep 2023 22:34:35 +0200 Subject: [PATCH 044/141] [java] Removing deprecated 'onConsoleLog', now use `onConsoleEntry` --- java/src/org/openqa/selenium/bidi/LogInspector.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/java/src/org/openqa/selenium/bidi/LogInspector.java b/java/src/org/openqa/selenium/bidi/LogInspector.java index 15e545bfe3e11..8c30a16a7a6e2 100644 --- a/java/src/org/openqa/selenium/bidi/LogInspector.java +++ b/java/src/org/openqa/selenium/bidi/LogInspector.java @@ -59,14 +59,6 @@ public LogInspector(Set browsingContextIds, WebDriver driver) { this.browsingContextIds = browsingContextIds; } - @Deprecated - public void onConsoleLog(Consumer consumer) { - Consumer logEntryConsumer = - logEntry -> logEntry.getConsoleLogEntry().ifPresent(consumer); - - addLogEntryAddedListener(logEntryConsumer); - } - public void onConsoleEntry(Consumer consumer) { Consumer logEntryConsumer = logEntry -> logEntry.getConsoleLogEntry().ifPresent(consumer); From eb73475a57193ab66d580de87c610ec302f5b9e3 Mon Sep 17 00:00:00 2001 From: Boni Garcia Date: Wed, 6 Sep 2023 17:06:32 +0200 Subject: [PATCH 045/141] [ci] Fix command to build SM in GH actions workflow using cross --- .github/workflows/build-selenium-manager.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-selenium-manager.yml b/.github/workflows/build-selenium-manager.yml index e24f73cbb1a2b..628969c0b2f34 100644 --- a/.github/workflows/build-selenium-manager.yml +++ b/.github/workflows/build-selenium-manager.yml @@ -46,8 +46,7 @@ jobs: - name: "Build release" run: | cd rust - rustup target add x86_64-unknown-linux-musl - cross build --release --target x86_64-unknown-linux-musl + cross build --target x86_64-unknown-linux-musl --release - name: "Tar binary (to keep executable permission)" run: | cd rust/target/x86_64-unknown-linux-musl/release From 938058d969de2d2512eb8e3a47acea022927c4f2 Mon Sep 17 00:00:00 2001 From: Boni Garcia Date: Wed, 6 Sep 2023 17:29:30 +0200 Subject: [PATCH 046/141] [ci] Display cross version in SM workflow for Linux --- .github/workflows/build-selenium-manager.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-selenium-manager.yml b/.github/workflows/build-selenium-manager.yml index 628969c0b2f34..f8f9b5bbb9c49 100644 --- a/.github/workflows/build-selenium-manager.yml +++ b/.github/workflows/build-selenium-manager.yml @@ -43,6 +43,7 @@ jobs: - name: "Install cross" run: | cargo install cross --git https://github.com/cross-rs/cross + cross -V - name: "Build release" run: | cd rust From 8fe35ca87321d6bd04c0e33cf114ac6dfa9ca386 Mon Sep 17 00:00:00 2001 From: Boni Garcia Date: Wed, 6 Sep 2023 18:08:11 +0200 Subject: [PATCH 047/141] [ci] Remove rust flags in Linux job for building SM --- .github/workflows/build-selenium-manager.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-selenium-manager.yml b/.github/workflows/build-selenium-manager.yml index f8f9b5bbb9c49..9b15f10ad098a 100644 --- a/.github/workflows/build-selenium-manager.yml +++ b/.github/workflows/build-selenium-manager.yml @@ -31,8 +31,6 @@ jobs: linux64: name: "[Linux x64] Build selenium-manager" runs-on: ubuntu-latest - env: - RUSTFLAGS: '-Ctarget-feature=-crt-static' steps: - name: "Checkout project" uses: actions/checkout@v3 From de4d2d56390cc17c37a8ce7c31f315e0f95338b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:52:59 +0200 Subject: [PATCH 048/141] Bump actions/checkout from 3 to 4 (#12687) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/bazel.yml | 2 +- .github/workflows/build-selenium-manager.yml | 6 +++--- .github/workflows/ci-javascript.yml | 2 +- .github/workflows/ci-python.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/label-commenter.yml | 2 +- .github/workflows/mirror-selenium-releases.yml | 2 +- .github/workflows/should-workflow-run.yml | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index ef8aa1e173f1e..5b10b6e4a52a3 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -57,7 +57,7 @@ jobs: SEL_M2_PASS: ${{ secrets.SEL_M2_PASS }} steps: - name: Checkout source tree - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Free space if: inputs.os != 'windows' run: ./scripts/github-actions/free-disk-space.sh diff --git a/.github/workflows/build-selenium-manager.yml b/.github/workflows/build-selenium-manager.yml index 9b15f10ad098a..92880db927845 100644 --- a/.github/workflows/build-selenium-manager.yml +++ b/.github/workflows/build-selenium-manager.yml @@ -10,7 +10,7 @@ jobs: RUSTFLAGS: '-Ctarget-feature=+crt-static' steps: - name: "Checkout project" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Update Rust" run: | rustup update @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest steps: - name: "Checkout project" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Update Rust" run: | rustup update @@ -64,7 +64,7 @@ jobs: RUSTFLAGS: '-Ctarget-feature=+crt-static' steps: - name: "Checkout project" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Update Rust" run: | rustup update diff --git a/.github/workflows/ci-javascript.yml b/.github/workflows/ci-javascript.yml index c320447f3c20a..384de680d1578 100644 --- a/.github/workflows/ci-javascript.yml +++ b/.github/workflows/ci-javascript.yml @@ -53,7 +53,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source tree - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v3 with: diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml index 613d4aa4a8192..5d09c6d971136 100644 --- a/.github/workflows/ci-python.yml +++ b/.github/workflows/ci-python.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout source tree - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.8 uses: actions/setup-python@v4 with: @@ -39,7 +39,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout source tree - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.8 uses: actions/setup-python@v4 with: @@ -61,7 +61,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout source tree - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.8 uses: actions/setup-python@v4 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 571d0930d2258..9a20e2719d5dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: targets: ${{ steps.check-targets.outputs.bazel-targets }} steps: - name: Checkout source tree - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 50 - name: Setup Bazel diff --git a/.github/workflows/label-commenter.yml b/.github/workflows/label-commenter.yml index 576e6f9e58896..08861192ac08c 100644 --- a/.github/workflows/label-commenter.yml +++ b/.github/workflows/label-commenter.yml @@ -13,6 +13,6 @@ jobs: comment: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Label Commenter uses: peaceiris/actions-label-commenter@v1 diff --git a/.github/workflows/mirror-selenium-releases.yml b/.github/workflows/mirror-selenium-releases.yml index ccee9522e5d0a..0c79cd1e4b5c4 100644 --- a/.github/workflows/mirror-selenium-releases.yml +++ b/.github/workflows/mirror-selenium-releases.yml @@ -9,7 +9,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: persist-credentials: false fetch-depth: 0 diff --git a/.github/workflows/should-workflow-run.yml b/.github/workflows/should-workflow-run.yml index 0766cd17bc14e..ce540e5df5001 100644 --- a/.github/workflows/should-workflow-run.yml +++ b/.github/workflows/should-workflow-run.yml @@ -25,7 +25,7 @@ jobs: result: ${{ steps.check-bazel-target-prefix.outputs.run-workflow }} steps: - name: Checkout source tree - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 50 - name: Setup Bazel From 4dbd6ba5dd690727fa35a5d83563baaa3f66c682 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 8 Sep 2023 00:01:35 +0300 Subject: [PATCH 049/141] [dotnet] Stabilize cdp network monitoring via increasing default timeout (#12701) Stabilize cdp network monitoring via increasing default timeout --- dotnet/src/webdriver/DevTools/DevToolsSession.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dotnet/src/webdriver/DevTools/DevToolsSession.cs b/dotnet/src/webdriver/DevTools/DevToolsSession.cs index 45adc7551f1ab..adbcb567a0a37 100644 --- a/dotnet/src/webdriver/DevTools/DevToolsSession.cs +++ b/dotnet/src/webdriver/DevTools/DevToolsSession.cs @@ -66,7 +66,7 @@ public DevToolsSession(string endpointAddress) throw new ArgumentNullException(nameof(endpointAddress)); } - this.CommandTimeout = TimeSpan.FromSeconds(5); + this.CommandTimeout = TimeSpan.FromSeconds(30); this.debuggerEndpoint = endpointAddress; if (endpointAddress.StartsWith("ws:")) { @@ -223,7 +223,7 @@ public T GetVersionSpecificDomains() where T : DevToolsSessionDomains if (!responseWasReceived && throwExceptionIfResponseNotReceived) { - throw new InvalidOperationException($"A command response was not received: {commandName}"); + throw new InvalidOperationException($"A command response was not received: {commandName}, timeout: {millisecondsTimeout.Value}ms"); } if (this.pendingCommands.TryRemove(message.CommandId, out DevToolsCommandData modified)) From 8c4f48c2a67312e61730bee60c15b320917dc31a Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 8 Sep 2023 00:06:52 +0300 Subject: [PATCH 050/141] [dotnet] Configure await false to all awaitable invocations (#12664) --- .../src/webdriver/DevTools/DevToolsSession.cs | 37 +++++++------ dotnet/src/webdriver/DevTools/Network.cs | 2 +- .../webdriver/DevTools/WebSocketConnection.cs | 18 +++---- .../webdriver/DevTools/v114/V114JavaScript.cs | 18 +++---- dotnet/src/webdriver/DevTools/v114/V114Log.cs | 6 +-- .../webdriver/DevTools/v114/V114Network.cs | 28 +++++----- .../src/webdriver/DevTools/v114/V114Target.cs | 8 +-- .../webdriver/DevTools/v115/V115JavaScript.cs | 18 +++---- dotnet/src/webdriver/DevTools/v115/V115Log.cs | 6 +-- .../webdriver/DevTools/v115/V115Network.cs | 36 ++++++------- .../src/webdriver/DevTools/v115/V115Target.cs | 8 +-- .../webdriver/DevTools/v116/V116JavaScript.cs | 18 +++---- dotnet/src/webdriver/DevTools/v116/V116Log.cs | 6 +-- .../webdriver/DevTools/v116/V116Network.cs | 36 ++++++------- .../src/webdriver/DevTools/v116/V116Target.cs | 8 +-- .../webdriver/DevTools/v85/V85JavaScript.cs | 18 +++---- dotnet/src/webdriver/DevTools/v85/V85Log.cs | 6 +-- .../src/webdriver/DevTools/v85/V85Network.cs | 38 +++++++------- .../src/webdriver/DevTools/v85/V85Target.cs | 8 +-- dotnet/src/webdriver/JavaScriptEngine.cs | 52 +++++++++---------- dotnet/src/webdriver/NetworkManager.cs | 24 ++++----- .../webdriver/Remote/HttpCommandExecutor.cs | 14 ++--- 22 files changed, 202 insertions(+), 211 deletions(-) diff --git a/dotnet/src/webdriver/DevTools/DevToolsSession.cs b/dotnet/src/webdriver/DevTools/DevToolsSession.cs index adbcb567a0a37..58b97e7961181 100644 --- a/dotnet/src/webdriver/DevTools/DevToolsSession.cs +++ b/dotnet/src/webdriver/DevTools/DevToolsSession.cs @@ -73,7 +73,6 @@ public DevToolsSession(string endpointAddress) this.websocketAddress = endpointAddress; } this.messageQueueMonitorTask = Task.Run(() => this.MonitorMessageQueue()); - this.messageQueueMonitorTask.ConfigureAwait(false); } ///

@@ -142,7 +141,7 @@ public T GetVersionSpecificDomains() where T : DevToolsSessionDomains throw new ArgumentNullException(nameof(command)); } - var result = await SendCommand(command.CommandName, JToken.FromObject(command), cancellationToken, millisecondsTimeout, throwExceptionIfResponseNotReceived); + var result = await SendCommand(command.CommandName, JToken.FromObject(command), cancellationToken, millisecondsTimeout, throwExceptionIfResponseNotReceived).ConfigureAwait(false); if (result == null) { @@ -176,7 +175,7 @@ public T GetVersionSpecificDomains() where T : DevToolsSessionDomains throw new ArgumentNullException(nameof(command)); } - var result = await SendCommand(command.CommandName, JToken.FromObject(command), cancellationToken, millisecondsTimeout, throwExceptionIfResponseNotReceived); + var result = await SendCommand(command.CommandName, JToken.FromObject(command), cancellationToken, millisecondsTimeout, throwExceptionIfResponseNotReceived).ConfigureAwait(false); if (result == null) { @@ -206,7 +205,7 @@ public T GetVersionSpecificDomains() where T : DevToolsSessionDomains if (this.attachedTargetId == null) { LogTrace("Session not currently attached to a target; reattaching"); - await this.InitializeSession(); + await this.InitializeSession().ConfigureAwait(false); } var message = new DevToolsCommandData(Interlocked.Increment(ref this.currentCommandId), this.ActiveSessionId, commandName, commandParameters); @@ -217,9 +216,9 @@ public T GetVersionSpecificDomains() where T : DevToolsSessionDomains string contents = JsonConvert.SerializeObject(message); this.pendingCommands.TryAdd(message.CommandId, message); - await this.connection.SendData(contents); + await this.connection.SendData(contents).ConfigureAwait(false); - var responseWasReceived = await Task.Run(() => message.SyncEvent.Wait(millisecondsTimeout.Value, cancellationToken)); + var responseWasReceived = message.SyncEvent.Wait(millisecondsTimeout.Value, cancellationToken); if (!responseWasReceived && throwExceptionIfResponseNotReceived) { @@ -272,15 +271,15 @@ public void Dispose() /// A task that represents the asynchronous operation. internal async Task StartSession(int requestedProtocolVersion) { - int protocolVersion = await InitializeProtocol(requestedProtocolVersion); + int protocolVersion = await InitializeProtocol(requestedProtocolVersion).ConfigureAwait(false); this.domains = DevToolsDomains.InitializeDomains(protocolVersion, this); - await this.InitializeSocketConnection(); - await this.InitializeSession(); + await this.InitializeSocketConnection().ConfigureAwait(false); + await this.InitializeSession().ConfigureAwait(false); try { // Wrap this in a try-catch, because it's not the end of the // world if clearing the log doesn't work. - await this.domains.Log.Clear(); + await this.domains.Log.Clear().ConfigureAwait(false); LogTrace("Log cleared.", this.attachedTargetId); } catch (WebDriverException) @@ -303,7 +302,7 @@ internal async Task StopSession(bool manualDetach) this.ActiveSessionId = null; if (manualDetach) { - await this.Domains.Target.DetachFromTarget(sessionId, this.attachedTargetId); + await this.Domains.Target.DetachFromTarget(sessionId, this.attachedTargetId).ConfigureAwait(false); } this.attachedTargetId = null; @@ -339,7 +338,7 @@ private async Task InitializeProtocol(int requestedProtocolVersion) using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(debuggerUrl); - rawVersionInfo = await client.GetStringAsync("/json/version"); + rawVersionInfo = await client.GetStringAsync("/json/version").ConfigureAwait(false); } var versionInfo = JsonConvert.DeserializeObject(rawVersionInfo); @@ -375,7 +374,7 @@ private async Task InitializeSession() // that when getting the available targets, we won't // recursively try to call InitializeSession. this.attachedTargetId = ""; - var targets = await this.domains.Target.GetTargets(); + var targets = await this.domains.Target.GetTargets().ConfigureAwait(false); foreach (var target in targets) { if (target.Type == "page") @@ -393,11 +392,11 @@ private async Task InitializeSession() throw new WebDriverException("Unable to find target to attach to, no taargets of type 'page' available"); } - string sessionId = await this.domains.Target.AttachToTarget(this.attachedTargetId); + string sessionId = await this.domains.Target.AttachToTarget(this.attachedTargetId).ConfigureAwait(false); LogTrace("Target ID {0} attached. Active session ID: {1}", this.attachedTargetId, sessionId); this.ActiveSessionId = sessionId; - await this.domains.Target.SetAutoAttach(); + await this.domains.Target.SetAutoAttach().ConfigureAwait(false); LogTrace("AutoAttach is set.", this.attachedTargetId); this.domains.Target.TargetDetached += this.OnTargetDetached; @@ -416,7 +415,7 @@ private async Task InitializeSocketConnection() LogTrace("Creating WebSocket"); this.connection = new WebSocketConnection(this.openConnectionWaitTimeSpan, this.closeConnectionWaitTimeSpan); connection.DataReceived += OnConnectionDataReceived; - await connection.Start(this.websocketAddress); + await connection.Start(this.websocketAddress).ConfigureAwait(false); LogTrace("WebSocket created"); } @@ -425,8 +424,8 @@ private async Task TerminateSocketConnection() LogTrace("Closing WebSocket"); if (this.connection != null && this.connection.IsActive) { - await this.connection.Stop(); - await this.ShutdownMessageQueue(); + await this.connection.Stop().ConfigureAwait(false); + await this.ShutdownMessageQueue().ConfigureAwait(false); } LogTrace("WebSocket closed"); } @@ -443,7 +442,7 @@ private async Task ShutdownMessageQueue() } this.messageQueue.CompleteAdding(); - await this.messageQueueMonitorTask; + await this.messageQueueMonitorTask.ConfigureAwait(false); } private void MonitorMessageQueue() diff --git a/dotnet/src/webdriver/DevTools/Network.cs b/dotnet/src/webdriver/DevTools/Network.cs index a928b982cab1f..eb300c4733b6b 100644 --- a/dotnet/src/webdriver/DevTools/Network.cs +++ b/dotnet/src/webdriver/DevTools/Network.cs @@ -78,7 +78,7 @@ public abstract class Network /// A task that represents the asynchronous operation. public async Task SetUserAgentOverride(string userAgent) { - await SetUserAgentOverride(new UserAgent() { UserAgentString = userAgent }); + await SetUserAgentOverride(new UserAgent() { UserAgentString = userAgent }).ConfigureAwait(false); } /// diff --git a/dotnet/src/webdriver/DevTools/WebSocketConnection.cs b/dotnet/src/webdriver/DevTools/WebSocketConnection.cs index 7eb315c25e409..f9f6838986bd8 100644 --- a/dotnet/src/webdriver/DevTools/WebSocketConnection.cs +++ b/dotnet/src/webdriver/DevTools/WebSocketConnection.cs @@ -102,14 +102,14 @@ public virtual async Task Start(string url) { try { - await this.client.ConnectAsync(new Uri(url), this.clientTokenSource.Token); + await this.client.ConnectAsync(new Uri(url), this.clientTokenSource.Token).ConfigureAwait(false); connected = true; } catch (WebSocketException) { // If the server-side socket is not yet ready, it leaves the client socket in a closed state, // which sees the object as disposed, so we must create a new one to try again - await Task.Delay(TimeSpan.FromMilliseconds(500)); + await Task.Delay(TimeSpan.FromMilliseconds(500)).ConfigureAwait(false); this.client = new ClientWebSocket(); } } @@ -137,7 +137,7 @@ public virtual async Task Stop() } else { - await this.CloseClientWebSocket(); + await this.CloseClientWebSocket().ConfigureAwait(false); } // Whether we closed the socket or timed out, we cancel the token causing ReceiveAsync to abort the socket. @@ -145,7 +145,7 @@ public virtual async Task Stop() this.clientTokenSource.Cancel(); if (this.dataReceiveTask != null) { - await this.dataReceiveTask; + await this.dataReceiveTask.ConfigureAwait(false); } this.client.Dispose(); @@ -165,7 +165,7 @@ public virtual async Task SendData(string data) try { - await this.client.SendAsync(messageBuffer, WebSocketMessageType.Text, endOfMessage: true, CancellationToken.None); + await this.client.SendAsync(messageBuffer, WebSocketMessageType.Text, endOfMessage: true, CancellationToken.None).ConfigureAwait(false); } finally { @@ -184,13 +184,13 @@ protected virtual async Task CloseClientWebSocket() try { // After this, the socket state which change to CloseSent - await this.client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Closing", timeout.Token); + await this.client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Closing", timeout.Token).ConfigureAwait(false); // Now we wait for the server response, which will close the socket while (this.client.State != WebSocketState.Closed && this.client.State != WebSocketState.Aborted && !timeout.Token.IsCancellationRequested) { // The loop may be too tight for the cancellation token to get triggered, so add a small delay - await Task.Delay(TimeSpan.FromMilliseconds(10)); + await Task.Delay(TimeSpan.FromMilliseconds(10)).ConfigureAwait(false); } this.Log($"Client state is {this.client.State}", DevToolsSessionLogLevel.Trace); @@ -238,7 +238,7 @@ private async Task ReceiveData() ArraySegment buffer = WebSocket.CreateClientBuffer(this.bufferSize, this.bufferSize); while (this.client.State != WebSocketState.Closed && !cancellationToken.IsCancellationRequested) { - WebSocketReceiveResult receiveResult = await this.client.ReceiveAsync(buffer, cancellationToken); + WebSocketReceiveResult receiveResult = await this.client.ReceiveAsync(buffer, cancellationToken).ConfigureAwait(false); // If the token is cancelled while ReceiveAsync is blocking, the socket state changes to aborted and it can't be used if (!cancellationToken.IsCancellationRequested) @@ -248,7 +248,7 @@ private async Task ReceiveData() if (receiveResult.MessageType == WebSocketMessageType.Close && this.client.State != WebSocketState.Closed && this.client.State != WebSocketState.CloseSent) { this.Log($"Acknowledging Close frame received from server (client state: {this.client.State})", DevToolsSessionLogLevel.Trace); - await this.client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Acknowledge Close frame", CancellationToken.None); + await this.client.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Acknowledge Close frame", CancellationToken.None).ConfigureAwait(false); } // Display text or binary data diff --git a/dotnet/src/webdriver/DevTools/v114/V114JavaScript.cs b/dotnet/src/webdriver/DevTools/v114/V114JavaScript.cs index 53b7de966ed9c..1a09d415f2435 100644 --- a/dotnet/src/webdriver/DevTools/v114/V114JavaScript.cs +++ b/dotnet/src/webdriver/DevTools/v114/V114JavaScript.cs @@ -51,7 +51,7 @@ public V114JavaScript(RuntimeAdapter runtime, PageAdapter page) /// A task that represents the asynchronous operation. public override async Task EnableRuntime() { - await runtime.Enable(); + await runtime.Enable().ConfigureAwait(false); } /// @@ -60,7 +60,7 @@ public override async Task EnableRuntime() /// A task that represents the asynchronous operation. public override async Task DisableRuntime() { - await runtime.Disable(); + await runtime.Disable().ConfigureAwait(false); } /// @@ -69,7 +69,7 @@ public override async Task DisableRuntime() /// A task that represents the asynchronous operation. public override async Task EnablePage() { - await page.Enable(); + await page.Enable().ConfigureAwait(false); } /// @@ -78,7 +78,7 @@ public override async Task EnablePage() /// A task that represents the asynchronous operation. public override async Task DisablePage() { - await page.Disable(); + await page.Disable().ConfigureAwait(false); } /// @@ -88,7 +88,7 @@ public override async Task DisablePage() /// A task that represents the asynchronous operation. public override async Task AddBinding(string name) { - await runtime.AddBinding(new AddBindingCommandSettings() { Name = name }); + await runtime.AddBinding(new AddBindingCommandSettings() { Name = name }).ConfigureAwait(false); } /// @@ -98,7 +98,7 @@ public override async Task AddBinding(string name) /// A task that represents the asynchronous operation. public override async Task RemoveBinding(string name) { - await runtime.RemoveBinding(new RemoveBindingCommandSettings() { Name = name }); + await runtime.RemoveBinding(new RemoveBindingCommandSettings() { Name = name }).ConfigureAwait(false); } /// @@ -108,7 +108,7 @@ public override async Task RemoveBinding(string name) /// A task that represents the asynchronous operation. The task result contains the internal ID of the script. public override async Task AddScriptToEvaluateOnNewDocument(string script) { - var result = await page.AddScriptToEvaluateOnNewDocument(new AddScriptToEvaluateOnNewDocumentCommandSettings() { Source = script }); + var result = await page.AddScriptToEvaluateOnNewDocument(new AddScriptToEvaluateOnNewDocumentCommandSettings() { Source = script }).ConfigureAwait(false); return result.Identifier; } @@ -119,7 +119,7 @@ public override async Task AddScriptToEvaluateOnNewDocument(string scrip /// A task that represents the asynchronous operation. public override async Task RemoveScriptToEvaluateOnNewDocument(string scriptId) { - await page.RemoveScriptToEvaluateOnNewDocument(new RemoveScriptToEvaluateOnNewDocumentCommandSettings() { Identifier = scriptId }); + await page.RemoveScriptToEvaluateOnNewDocument(new RemoveScriptToEvaluateOnNewDocumentCommandSettings() { Identifier = scriptId }).ConfigureAwait(false); } /// @@ -133,7 +133,7 @@ public override async Task RemoveScriptToEvaluateOnNewDocument(string scriptId) /// internal override async Task Evaluate(string script) { - await runtime.Evaluate(new EvaluateCommandSettings { Expression = script }); + await runtime.Evaluate(new EvaluateCommandSettings { Expression = script }).ConfigureAwait(false); } private void OnRuntimeBindingCalled(object sender, Runtime.BindingCalledEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v114/V114Log.cs b/dotnet/src/webdriver/DevTools/v114/V114Log.cs index 337aed24e8a0f..2b4b55121b5eb 100644 --- a/dotnet/src/webdriver/DevTools/v114/V114Log.cs +++ b/dotnet/src/webdriver/DevTools/v114/V114Log.cs @@ -47,7 +47,7 @@ public V114Log(LogAdapter adapter) /// A task that represents the asynchronous operation. public override async Task Enable() { - await adapter.Enable(); + await adapter.Enable().ConfigureAwait(false); } /// @@ -56,7 +56,7 @@ public override async Task Enable() /// A task that represents the asynchronous operation. public override async Task Disable() { - await adapter.Disable(); + await adapter.Disable().ConfigureAwait(false); } /// @@ -65,7 +65,7 @@ public override async Task Disable() /// A task that represents the asynchronous operation. public override async Task Clear() { - await adapter.Clear(); + await adapter.Clear().ConfigureAwait(false); } private void OnAdapterEntryAdded(object sender, Log.EntryAddedEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v114/V114Network.cs b/dotnet/src/webdriver/DevTools/v114/V114Network.cs index 5afc4784a87fe..0036444f5fc5d 100644 --- a/dotnet/src/webdriver/DevTools/v114/V114Network.cs +++ b/dotnet/src/webdriver/DevTools/v114/V114Network.cs @@ -52,7 +52,7 @@ public V114Network(NetworkAdapter network, FetchAdapter fetch) /// A task that represents the asynchronous operation. public override async Task DisableNetworkCaching() { - await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = true }); + await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = true }).ConfigureAwait(false); } /// @@ -61,7 +61,7 @@ public override async Task DisableNetworkCaching() /// A task that represents the asynchronous operation. public override async Task EnableNetworkCaching() { - await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = false }); + await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = false }).ConfigureAwait(false); } /// @@ -70,7 +70,7 @@ public override async Task EnableNetworkCaching() /// A task that represents the asynchronous operation. public override async Task EnableNetwork() { - await network.Enable(new Network.EnableCommandSettings()); + await network.Enable(new Network.EnableCommandSettings()).ConfigureAwait(false); } /// @@ -79,7 +79,7 @@ public override async Task EnableNetwork() /// A task that represents the asynchronous operation. public override async Task DisableNetwork() { - await network.Disable(); + await network.Disable().ConfigureAwait(false); } /// @@ -96,7 +96,7 @@ await fetch.Enable(new OpenQA.Selenium.DevTools.V114.Fetch.EnableCommandSettings new OpenQA.Selenium.DevTools.V114.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response } }, HandleAuthRequests = true - }); + }).ConfigureAwait(false); } /// @@ -105,7 +105,7 @@ await fetch.Enable(new OpenQA.Selenium.DevTools.V114.Fetch.EnableCommandSettings /// A task that represents the asynchronous operation. public override async Task DisableFetch() { - await fetch.Disable(); + await fetch.Disable().ConfigureAwait(false); } /// @@ -120,7 +120,7 @@ await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() UserAgent = userAgent.UserAgentString, AcceptLanguage = userAgent.AcceptLanguage, Platform = userAgent.Platform - }); + }).ConfigureAwait(false); } /// @@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData) commandSettings.PostData = Convert.ToBase64String(Encoding.UTF8.GetBytes(requestData.PostData)); } - await fetch.ContinueRequest(commandSettings); + await fetch.ContinueRequest(commandSettings).ConfigureAwait(false); } /// @@ -191,7 +191,7 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa commandSettings.Body = Convert.ToBase64String(Encoding.UTF8.GetBytes(responseData.Body)); } - await fetch.FulfillRequest(commandSettings); + await fetch.FulfillRequest(commandSettings).ConfigureAwait(false); } /// @@ -201,7 +201,7 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa /// A task that represents the asynchronous operation. public override async Task ContinueRequestWithoutModification(HttpRequestData requestData) { - await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }); + await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }).ConfigureAwait(false); } /// @@ -222,7 +222,7 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() Username = userName, Password = password } - }); + }).ConfigureAwait(false); } /// @@ -239,7 +239,7 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() { Response = V114.Fetch.AuthChallengeResponseResponseValues.CancelAuth } - }); + }).ConfigureAwait(false); } /// @@ -252,7 +252,7 @@ public override async Task AddResponseBody(HttpResponseData responseData) // If the response is a redirect, retrieving the body will throw an error in CDP. if (responseData.StatusCode < 300 || responseData.StatusCode > 399) { - var bodyResponse = await fetch.GetResponseBody(new Fetch.GetResponseBodyCommandSettings() { RequestId = responseData.RequestId }); + var bodyResponse = await fetch.GetResponseBody(new Fetch.GetResponseBodyCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); if (bodyResponse.Base64Encoded) { responseData.Body = Encoding.UTF8.GetString(Convert.FromBase64String(bodyResponse.Body)); @@ -271,7 +271,7 @@ public override async Task AddResponseBody(HttpResponseData responseData) /// A task that represents the asynchronous operation. public override async Task ContinueResponseWithoutModification(HttpResponseData responseData) { - await fetch.ContinueResponse(new ContinueResponseCommandSettings() { RequestId = responseData.RequestId }); + await fetch.ContinueResponse(new ContinueResponseCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); } private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v114/V114Target.cs b/dotnet/src/webdriver/DevTools/v114/V114Target.cs index 94765fa27e5e4..1eb62eea9e482 100644 --- a/dotnet/src/webdriver/DevTools/v114/V114Target.cs +++ b/dotnet/src/webdriver/DevTools/v114/V114Target.cs @@ -58,7 +58,7 @@ public override async Task> GetTargets(Object set { settings = new GetTargetsCommandSettings(); } - var response = await adapter.GetTargets((GetTargetsCommandSettings) settings); + var response = await adapter.GetTargets((GetTargetsCommandSettings) settings).ConfigureAwait(false); for (int i = 0; i < response.TargetInfos.Length; i++) { var targetInfo = response.TargetInfos[i]; @@ -88,7 +88,7 @@ public override async Task> GetTargets(Object set /// public override async Task AttachToTarget(string targetId) { - var result = await adapter.AttachToTarget(new AttachToTargetCommandSettings() { TargetId = targetId, Flatten = true }); + var result = await adapter.AttachToTarget(new AttachToTargetCommandSettings() { TargetId = targetId, Flatten = true }).ConfigureAwait(false); return result.SessionId; } @@ -104,7 +104,7 @@ await adapter.DetachFromTarget(new DetachFromTargetCommandSettings() { SessionId = sessionId, TargetId = targetId - }); + }).ConfigureAwait(false); } /// @@ -113,7 +113,7 @@ await adapter.DetachFromTarget(new DetachFromTargetCommandSettings() /// A task that represents the asynchronous operation. public override async Task SetAutoAttach() { - await adapter.SetAutoAttach(new SetAutoAttachCommandSettings() { AutoAttach = true, WaitForDebuggerOnStart = false, Flatten = true }); + await adapter.SetAutoAttach(new SetAutoAttachCommandSettings() { AutoAttach = true, WaitForDebuggerOnStart = false, Flatten = true }).ConfigureAwait(false); } private void OnDetachedFromTarget(object sender, DetachedFromTargetEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v115/V115JavaScript.cs b/dotnet/src/webdriver/DevTools/v115/V115JavaScript.cs index e949cbad69713..30605db994601 100644 --- a/dotnet/src/webdriver/DevTools/v115/V115JavaScript.cs +++ b/dotnet/src/webdriver/DevTools/v115/V115JavaScript.cs @@ -51,7 +51,7 @@ public V115JavaScript(RuntimeAdapter runtime, PageAdapter page) /// A task that represents the asynchronous operation. public override async Task EnableRuntime() { - await runtime.Enable(); + await runtime.Enable().ConfigureAwait(false); } /// @@ -60,7 +60,7 @@ public override async Task EnableRuntime() /// A task that represents the asynchronous operation. public override async Task DisableRuntime() { - await runtime.Disable(); + await runtime.Disable().ConfigureAwait(false); } /// @@ -69,7 +69,7 @@ public override async Task DisableRuntime() /// A task that represents the asynchronous operation. public override async Task EnablePage() { - await page.Enable(); + await page.Enable().ConfigureAwait(false); } /// @@ -78,7 +78,7 @@ public override async Task EnablePage() /// A task that represents the asynchronous operation. public override async Task DisablePage() { - await page.Disable(); + await page.Disable().ConfigureAwait(false); } /// @@ -88,7 +88,7 @@ public override async Task DisablePage() /// A task that represents the asynchronous operation. public override async Task AddBinding(string name) { - await runtime.AddBinding(new AddBindingCommandSettings() { Name = name }); + await runtime.AddBinding(new AddBindingCommandSettings() { Name = name }).ConfigureAwait(false); } /// @@ -98,7 +98,7 @@ public override async Task AddBinding(string name) /// A task that represents the asynchronous operation. public override async Task RemoveBinding(string name) { - await runtime.RemoveBinding(new RemoveBindingCommandSettings() { Name = name }); + await runtime.RemoveBinding(new RemoveBindingCommandSettings() { Name = name }).ConfigureAwait(false); } /// @@ -108,7 +108,7 @@ public override async Task RemoveBinding(string name) /// A task that represents the asynchronous operation. The task result contains the internal ID of the script. public override async Task AddScriptToEvaluateOnNewDocument(string script) { - var result = await page.AddScriptToEvaluateOnNewDocument(new AddScriptToEvaluateOnNewDocumentCommandSettings() { Source = script }); + var result = await page.AddScriptToEvaluateOnNewDocument(new AddScriptToEvaluateOnNewDocumentCommandSettings() { Source = script }).ConfigureAwait(false); return result.Identifier; } @@ -119,7 +119,7 @@ public override async Task AddScriptToEvaluateOnNewDocument(string scrip /// A task that represents the asynchronous operation. public override async Task RemoveScriptToEvaluateOnNewDocument(string scriptId) { - await page.RemoveScriptToEvaluateOnNewDocument(new RemoveScriptToEvaluateOnNewDocumentCommandSettings() { Identifier = scriptId }); + await page.RemoveScriptToEvaluateOnNewDocument(new RemoveScriptToEvaluateOnNewDocumentCommandSettings() { Identifier = scriptId }).ConfigureAwait(false); } /// @@ -133,7 +133,7 @@ public override async Task RemoveScriptToEvaluateOnNewDocument(string scriptId) /// internal override async Task Evaluate(string script) { - await runtime.Evaluate(new EvaluateCommandSettings { Expression = script }); + await runtime.Evaluate(new EvaluateCommandSettings { Expression = script }).ConfigureAwait(false); } private void OnRuntimeBindingCalled(object sender, Runtime.BindingCalledEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v115/V115Log.cs b/dotnet/src/webdriver/DevTools/v115/V115Log.cs index c795358583593..c2d1611c33a67 100644 --- a/dotnet/src/webdriver/DevTools/v115/V115Log.cs +++ b/dotnet/src/webdriver/DevTools/v115/V115Log.cs @@ -47,7 +47,7 @@ public V115Log(LogAdapter adapter) /// A task that represents the asynchronous operation. public override async Task Enable() { - await adapter.Enable(); + await adapter.Enable().ConfigureAwait(false); } /// @@ -56,7 +56,7 @@ public override async Task Enable() /// A task that represents the asynchronous operation. public override async Task Disable() { - await adapter.Disable(); + await adapter.Disable().ConfigureAwait(false); } /// @@ -65,7 +65,7 @@ public override async Task Disable() /// A task that represents the asynchronous operation. public override async Task Clear() { - await adapter.Clear(); + await adapter.Clear().ConfigureAwait(false); } private void OnAdapterEntryAdded(object sender, Log.EntryAddedEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v115/V115Network.cs b/dotnet/src/webdriver/DevTools/v115/V115Network.cs index 148702b1188f5..6fbf3930173e5 100644 --- a/dotnet/src/webdriver/DevTools/v115/V115Network.cs +++ b/dotnet/src/webdriver/DevTools/v115/V115Network.cs @@ -52,7 +52,7 @@ public V115Network(NetworkAdapter network, FetchAdapter fetch) /// A task that represents the asynchronous operation. public override async Task DisableNetworkCaching() { - await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = true }); + await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = true }).ConfigureAwait(false); } /// @@ -61,7 +61,7 @@ public override async Task DisableNetworkCaching() /// A task that represents the asynchronous operation. public override async Task EnableNetworkCaching() { - await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = false }); + await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = false }).ConfigureAwait(false); } /// @@ -70,7 +70,7 @@ public override async Task EnableNetworkCaching() /// A task that represents the asynchronous operation. public override async Task EnableNetwork() { - await network.Enable(new Network.EnableCommandSettings()); + await network.Enable(new Network.EnableCommandSettings()).ConfigureAwait(false); } /// @@ -79,7 +79,7 @@ public override async Task EnableNetwork() /// A task that represents the asynchronous operation. public override async Task DisableNetwork() { - await network.Disable(); + await network.Disable().ConfigureAwait(false); } /// @@ -88,15 +88,15 @@ public override async Task DisableNetwork() /// A task that represents the asynchronous operation. public override async Task EnableFetchForAllPatterns() { - await fetch.Enable(new OpenQA.Selenium.DevTools.V115.Fetch.EnableCommandSettings() + await fetch.Enable(new Fetch.EnableCommandSettings() { - Patterns = new OpenQA.Selenium.DevTools.V115.Fetch.RequestPattern[] + Patterns = new Fetch.RequestPattern[] { - new OpenQA.Selenium.DevTools.V115.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request }, - new OpenQA.Selenium.DevTools.V115.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response } + new Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request }, + new Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response } }, HandleAuthRequests = true - }); + }).ConfigureAwait(false); } /// @@ -105,7 +105,7 @@ await fetch.Enable(new OpenQA.Selenium.DevTools.V115.Fetch.EnableCommandSettings /// A task that represents the asynchronous operation. public override async Task DisableFetch() { - await fetch.Disable(); + await fetch.Disable().ConfigureAwait(false); } /// @@ -120,7 +120,7 @@ await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() UserAgent = userAgent.UserAgentString, AcceptLanguage = userAgent.AcceptLanguage, Platform = userAgent.Platform - }); + }).ConfigureAwait(false); } /// @@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData) commandSettings.PostData = Convert.ToBase64String(Encoding.UTF8.GetBytes(requestData.PostData)); } - await fetch.ContinueRequest(commandSettings); + await fetch.ContinueRequest(commandSettings).ConfigureAwait(false); } /// @@ -191,7 +191,7 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa commandSettings.Body = Convert.ToBase64String(Encoding.UTF8.GetBytes(responseData.Body)); } - await fetch.FulfillRequest(commandSettings); + await fetch.FulfillRequest(commandSettings).ConfigureAwait(false); } /// @@ -201,7 +201,7 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa /// A task that represents the asynchronous operation. public override async Task ContinueRequestWithoutModification(HttpRequestData requestData) { - await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }); + await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }).ConfigureAwait(false); } /// @@ -222,7 +222,7 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() Username = userName, Password = password } - }); + }).ConfigureAwait(false); } /// @@ -239,7 +239,7 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() { Response = V115.Fetch.AuthChallengeResponseResponseValues.CancelAuth } - }); + }).ConfigureAwait(false); } /// @@ -252,7 +252,7 @@ public override async Task AddResponseBody(HttpResponseData responseData) // If the response is a redirect, retrieving the body will throw an error in CDP. if (responseData.StatusCode < 300 || responseData.StatusCode > 399) { - var bodyResponse = await fetch.GetResponseBody(new Fetch.GetResponseBodyCommandSettings() { RequestId = responseData.RequestId }); + var bodyResponse = await fetch.GetResponseBody(new Fetch.GetResponseBodyCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); if (bodyResponse != null) { if (bodyResponse.Base64Encoded) @@ -274,7 +274,7 @@ public override async Task AddResponseBody(HttpResponseData responseData) /// A task that represents the asynchronous operation. public override async Task ContinueResponseWithoutModification(HttpResponseData responseData) { - await fetch.ContinueResponse(new ContinueResponseCommandSettings() { RequestId = responseData.RequestId }); + await fetch.ContinueResponse(new ContinueResponseCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); } private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v115/V115Target.cs b/dotnet/src/webdriver/DevTools/v115/V115Target.cs index bae2c204717ce..1e4f10f3ac885 100644 --- a/dotnet/src/webdriver/DevTools/v115/V115Target.cs +++ b/dotnet/src/webdriver/DevTools/v115/V115Target.cs @@ -58,7 +58,7 @@ public override async Task> GetTargets(Object set { settings = new GetTargetsCommandSettings(); } - var response = await adapter.GetTargets((GetTargetsCommandSettings) settings); + var response = await adapter.GetTargets((GetTargetsCommandSettings) settings).ConfigureAwait(false); for (int i = 0; i < response.TargetInfos.Length; i++) { var targetInfo = response.TargetInfos[i]; @@ -88,7 +88,7 @@ public override async Task> GetTargets(Object set /// public override async Task AttachToTarget(string targetId) { - var result = await adapter.AttachToTarget(new AttachToTargetCommandSettings() { TargetId = targetId, Flatten = true }); + var result = await adapter.AttachToTarget(new AttachToTargetCommandSettings() { TargetId = targetId, Flatten = true }).ConfigureAwait(false); return result.SessionId; } @@ -104,7 +104,7 @@ await adapter.DetachFromTarget(new DetachFromTargetCommandSettings() { SessionId = sessionId, TargetId = targetId - }); + }).ConfigureAwait(false); } /// @@ -113,7 +113,7 @@ await adapter.DetachFromTarget(new DetachFromTargetCommandSettings() /// A task that represents the asynchronous operation. public override async Task SetAutoAttach() { - await adapter.SetAutoAttach(new SetAutoAttachCommandSettings() { AutoAttach = true, WaitForDebuggerOnStart = false, Flatten = true }); + await adapter.SetAutoAttach(new SetAutoAttachCommandSettings() { AutoAttach = true, WaitForDebuggerOnStart = false, Flatten = true }).ConfigureAwait(false); } private void OnDetachedFromTarget(object sender, DetachedFromTargetEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v116/V116JavaScript.cs b/dotnet/src/webdriver/DevTools/v116/V116JavaScript.cs index 8a5e08bbbef30..d554d026c2c4c 100644 --- a/dotnet/src/webdriver/DevTools/v116/V116JavaScript.cs +++ b/dotnet/src/webdriver/DevTools/v116/V116JavaScript.cs @@ -51,7 +51,7 @@ public V116JavaScript(RuntimeAdapter runtime, PageAdapter page) /// A task that represents the asynchronous operation. public override async Task EnableRuntime() { - await runtime.Enable(); + await runtime.Enable().ConfigureAwait(false); } /// @@ -60,7 +60,7 @@ public override async Task EnableRuntime() /// A task that represents the asynchronous operation. public override async Task DisableRuntime() { - await runtime.Disable(); + await runtime.Disable().ConfigureAwait(false); } /// @@ -69,7 +69,7 @@ public override async Task DisableRuntime() /// A task that represents the asynchronous operation. public override async Task EnablePage() { - await page.Enable(); + await page.Enable().ConfigureAwait(false); } /// @@ -78,7 +78,7 @@ public override async Task EnablePage() /// A task that represents the asynchronous operation. public override async Task DisablePage() { - await page.Disable(); + await page.Disable().ConfigureAwait(false); } /// @@ -88,7 +88,7 @@ public override async Task DisablePage() /// A task that represents the asynchronous operation. public override async Task AddBinding(string name) { - await runtime.AddBinding(new AddBindingCommandSettings() { Name = name }); + await runtime.AddBinding(new AddBindingCommandSettings() { Name = name }).ConfigureAwait(false); } /// @@ -98,7 +98,7 @@ public override async Task AddBinding(string name) /// A task that represents the asynchronous operation. public override async Task RemoveBinding(string name) { - await runtime.RemoveBinding(new RemoveBindingCommandSettings() { Name = name }); + await runtime.RemoveBinding(new RemoveBindingCommandSettings() { Name = name }).ConfigureAwait(false); } /// @@ -108,7 +108,7 @@ public override async Task RemoveBinding(string name) /// A task that represents the asynchronous operation. The task result contains the internal ID of the script. public override async Task AddScriptToEvaluateOnNewDocument(string script) { - var result = await page.AddScriptToEvaluateOnNewDocument(new AddScriptToEvaluateOnNewDocumentCommandSettings() { Source = script }); + var result = await page.AddScriptToEvaluateOnNewDocument(new AddScriptToEvaluateOnNewDocumentCommandSettings() { Source = script }).ConfigureAwait(false); return result.Identifier; } @@ -119,7 +119,7 @@ public override async Task AddScriptToEvaluateOnNewDocument(string scrip /// A task that represents the asynchronous operation. public override async Task RemoveScriptToEvaluateOnNewDocument(string scriptId) { - await page.RemoveScriptToEvaluateOnNewDocument(new RemoveScriptToEvaluateOnNewDocumentCommandSettings() { Identifier = scriptId }); + await page.RemoveScriptToEvaluateOnNewDocument(new RemoveScriptToEvaluateOnNewDocumentCommandSettings() { Identifier = scriptId }).ConfigureAwait(false); } /// @@ -133,7 +133,7 @@ public override async Task RemoveScriptToEvaluateOnNewDocument(string scriptId) /// internal override async Task Evaluate(string script) { - await runtime.Evaluate(new EvaluateCommandSettings { Expression = script }); + await runtime.Evaluate(new EvaluateCommandSettings { Expression = script }).ConfigureAwait(false); } private void OnRuntimeBindingCalled(object sender, Runtime.BindingCalledEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v116/V116Log.cs b/dotnet/src/webdriver/DevTools/v116/V116Log.cs index 0c04cc431b421..bee566c9ba6ef 100644 --- a/dotnet/src/webdriver/DevTools/v116/V116Log.cs +++ b/dotnet/src/webdriver/DevTools/v116/V116Log.cs @@ -47,7 +47,7 @@ public V116Log(LogAdapter adapter) /// A task that represents the asynchronous operation. public override async Task Enable() { - await adapter.Enable(); + await adapter.Enable().ConfigureAwait(false); } /// @@ -56,7 +56,7 @@ public override async Task Enable() /// A task that represents the asynchronous operation. public override async Task Disable() { - await adapter.Disable(); + await adapter.Disable().ConfigureAwait(false); } /// @@ -65,7 +65,7 @@ public override async Task Disable() /// A task that represents the asynchronous operation. public override async Task Clear() { - await adapter.Clear(); + await adapter.Clear().ConfigureAwait(false); } private void OnAdapterEntryAdded(object sender, Log.EntryAddedEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v116/V116Network.cs b/dotnet/src/webdriver/DevTools/v116/V116Network.cs index b0dcb1d27b973..e1a9c646f8096 100644 --- a/dotnet/src/webdriver/DevTools/v116/V116Network.cs +++ b/dotnet/src/webdriver/DevTools/v116/V116Network.cs @@ -52,7 +52,7 @@ public V116Network(NetworkAdapter network, FetchAdapter fetch) /// A task that represents the asynchronous operation. public override async Task DisableNetworkCaching() { - await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = true }); + await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = true }).ConfigureAwait(false); } /// @@ -61,7 +61,7 @@ public override async Task DisableNetworkCaching() /// A task that represents the asynchronous operation. public override async Task EnableNetworkCaching() { - await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = false }); + await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = false }).ConfigureAwait(false); } /// @@ -70,7 +70,7 @@ public override async Task EnableNetworkCaching() /// A task that represents the asynchronous operation. public override async Task EnableNetwork() { - await network.Enable(new Network.EnableCommandSettings()); + await network.Enable(new Network.EnableCommandSettings()).ConfigureAwait(false); } /// @@ -79,7 +79,7 @@ public override async Task EnableNetwork() /// A task that represents the asynchronous operation. public override async Task DisableNetwork() { - await network.Disable(); + await network.Disable().ConfigureAwait(false); } /// @@ -88,15 +88,15 @@ public override async Task DisableNetwork() /// A task that represents the asynchronous operation. public override async Task EnableFetchForAllPatterns() { - await fetch.Enable(new OpenQA.Selenium.DevTools.V116.Fetch.EnableCommandSettings() + await fetch.Enable(new Fetch.EnableCommandSettings() { - Patterns = new OpenQA.Selenium.DevTools.V116.Fetch.RequestPattern[] + Patterns = new Fetch.RequestPattern[] { - new OpenQA.Selenium.DevTools.V116.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request }, - new OpenQA.Selenium.DevTools.V116.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response } + new Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request }, + new Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response } }, HandleAuthRequests = true - }); + }).ConfigureAwait(false); } /// @@ -105,7 +105,7 @@ await fetch.Enable(new OpenQA.Selenium.DevTools.V116.Fetch.EnableCommandSettings /// A task that represents the asynchronous operation. public override async Task DisableFetch() { - await fetch.Disable(); + await fetch.Disable().ConfigureAwait(false); } /// @@ -120,7 +120,7 @@ await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() UserAgent = userAgent.UserAgentString, AcceptLanguage = userAgent.AcceptLanguage, Platform = userAgent.Platform - }); + }).ConfigureAwait(false); } /// @@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData) commandSettings.PostData = Convert.ToBase64String(Encoding.UTF8.GetBytes(requestData.PostData)); } - await fetch.ContinueRequest(commandSettings); + await fetch.ContinueRequest(commandSettings).ConfigureAwait(false); } /// @@ -191,7 +191,7 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa commandSettings.Body = Convert.ToBase64String(Encoding.UTF8.GetBytes(responseData.Body)); } - await fetch.FulfillRequest(commandSettings); + await fetch.FulfillRequest(commandSettings).ConfigureAwait(false); } /// @@ -201,7 +201,7 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa /// A task that represents the asynchronous operation. public override async Task ContinueRequestWithoutModification(HttpRequestData requestData) { - await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }); + await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }).ConfigureAwait(false); } /// @@ -222,7 +222,7 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() Username = userName, Password = password } - }); + }).ConfigureAwait(false); } /// @@ -239,7 +239,7 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() { Response = V116.Fetch.AuthChallengeResponseResponseValues.CancelAuth } - }); + }).ConfigureAwait(false); } /// @@ -252,7 +252,7 @@ public override async Task AddResponseBody(HttpResponseData responseData) // If the response is a redirect, retrieving the body will throw an error in CDP. if (responseData.StatusCode < 300 || responseData.StatusCode > 399) { - var bodyResponse = await fetch.GetResponseBody(new Fetch.GetResponseBodyCommandSettings() { RequestId = responseData.RequestId }); + var bodyResponse = await fetch.GetResponseBody(new Fetch.GetResponseBodyCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); if (bodyResponse != null) { if (bodyResponse.Base64Encoded) @@ -274,7 +274,7 @@ public override async Task AddResponseBody(HttpResponseData responseData) /// A task that represents the asynchronous operation. public override async Task ContinueResponseWithoutModification(HttpResponseData responseData) { - await fetch.ContinueResponse(new ContinueResponseCommandSettings() { RequestId = responseData.RequestId }); + await fetch.ContinueResponse(new ContinueResponseCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); } private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v116/V116Target.cs b/dotnet/src/webdriver/DevTools/v116/V116Target.cs index 055f35f40c7aa..b2c3236c9ce26 100644 --- a/dotnet/src/webdriver/DevTools/v116/V116Target.cs +++ b/dotnet/src/webdriver/DevTools/v116/V116Target.cs @@ -58,7 +58,7 @@ public override async Task> GetTargets(Object set { settings = new GetTargetsCommandSettings(); } - var response = await adapter.GetTargets((GetTargetsCommandSettings) settings); + var response = await adapter.GetTargets((GetTargetsCommandSettings) settings).ConfigureAwait(false); for (int i = 0; i < response.TargetInfos.Length; i++) { var targetInfo = response.TargetInfos[i]; @@ -88,7 +88,7 @@ public override async Task> GetTargets(Object set /// public override async Task AttachToTarget(string targetId) { - var result = await adapter.AttachToTarget(new AttachToTargetCommandSettings() { TargetId = targetId, Flatten = true }); + var result = await adapter.AttachToTarget(new AttachToTargetCommandSettings() { TargetId = targetId, Flatten = true }).ConfigureAwait(false); return result.SessionId; } @@ -104,7 +104,7 @@ await adapter.DetachFromTarget(new DetachFromTargetCommandSettings() { SessionId = sessionId, TargetId = targetId - }); + }).ConfigureAwait(false); } /// @@ -113,7 +113,7 @@ await adapter.DetachFromTarget(new DetachFromTargetCommandSettings() /// A task that represents the asynchronous operation. public override async Task SetAutoAttach() { - await adapter.SetAutoAttach(new SetAutoAttachCommandSettings() { AutoAttach = true, WaitForDebuggerOnStart = false, Flatten = true }); + await adapter.SetAutoAttach(new SetAutoAttachCommandSettings() { AutoAttach = true, WaitForDebuggerOnStart = false, Flatten = true }).ConfigureAwait(false); } private void OnDetachedFromTarget(object sender, DetachedFromTargetEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v85/V85JavaScript.cs b/dotnet/src/webdriver/DevTools/v85/V85JavaScript.cs index 092779b2d743b..b7f921cca0deb 100644 --- a/dotnet/src/webdriver/DevTools/v85/V85JavaScript.cs +++ b/dotnet/src/webdriver/DevTools/v85/V85JavaScript.cs @@ -51,7 +51,7 @@ public V85JavaScript(RuntimeAdapter runtime, PageAdapter page) /// A task that represents the asynchronous operation. public override async Task EnableRuntime() { - await runtime.Enable(); + await runtime.Enable().ConfigureAwait(false); } /// @@ -60,7 +60,7 @@ public override async Task EnableRuntime() /// A task that represents the asynchronous operation. public override async Task DisableRuntime() { - await runtime.Disable(); + await runtime.Disable().ConfigureAwait(false); } /// @@ -69,7 +69,7 @@ public override async Task DisableRuntime() /// A task that represents the asynchronous operation. public override async Task EnablePage() { - await page.Enable(); + await page.Enable().ConfigureAwait(false); } /// @@ -78,7 +78,7 @@ public override async Task EnablePage() /// A task that represents the asynchronous operation. public override async Task DisablePage() { - await page.Disable(); + await page.Disable().ConfigureAwait(false); } /// @@ -88,7 +88,7 @@ public override async Task DisablePage() /// A task that represents the asynchronous operation. public override async Task AddBinding(string name) { - await runtime.AddBinding(new AddBindingCommandSettings() { Name = name }); + await runtime.AddBinding(new AddBindingCommandSettings() { Name = name }).ConfigureAwait(false); } /// @@ -98,7 +98,7 @@ public override async Task AddBinding(string name) /// A task that represents the asynchronous operation. public override async Task RemoveBinding(string name) { - await runtime.RemoveBinding(new RemoveBindingCommandSettings() { Name = name }); + await runtime.RemoveBinding(new RemoveBindingCommandSettings() { Name = name }).ConfigureAwait(false); } /// @@ -108,7 +108,7 @@ public override async Task RemoveBinding(string name) /// A task that represents the asynchronous operation. The task result contains the internal ID of the script. public override async Task AddScriptToEvaluateOnNewDocument(string script) { - var result = await page.AddScriptToEvaluateOnNewDocument(new AddScriptToEvaluateOnNewDocumentCommandSettings() { Source = script }); + var result = await page.AddScriptToEvaluateOnNewDocument(new AddScriptToEvaluateOnNewDocumentCommandSettings() { Source = script }).ConfigureAwait(false); return result.Identifier; } @@ -119,7 +119,7 @@ public override async Task AddScriptToEvaluateOnNewDocument(string scrip /// A task that represents the asynchronous operation. public override async Task RemoveScriptToEvaluateOnNewDocument(string scriptId) { - await page.RemoveScriptToEvaluateOnNewDocument(new RemoveScriptToEvaluateOnNewDocumentCommandSettings() { Identifier = scriptId }); + await page.RemoveScriptToEvaluateOnNewDocument(new RemoveScriptToEvaluateOnNewDocumentCommandSettings() { Identifier = scriptId }).ConfigureAwait(false); } /// @@ -133,7 +133,7 @@ public override async Task RemoveScriptToEvaluateOnNewDocument(string scriptId) /// internal override async Task Evaluate(string script) { - await runtime.Evaluate(new EvaluateCommandSettings { Expression = script }); + await runtime.Evaluate(new EvaluateCommandSettings { Expression = script }).ConfigureAwait(false); } private void OnRuntimeBindingCalled(object sender, Runtime.BindingCalledEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v85/V85Log.cs b/dotnet/src/webdriver/DevTools/v85/V85Log.cs index 4454399224f18..483ca127fba76 100644 --- a/dotnet/src/webdriver/DevTools/v85/V85Log.cs +++ b/dotnet/src/webdriver/DevTools/v85/V85Log.cs @@ -47,7 +47,7 @@ public V85Log(LogAdapter adapter) /// A task that represents the asynchronous operation. public override async Task Enable() { - await adapter.Enable(); + await adapter.Enable().ConfigureAwait(false); } /// @@ -56,7 +56,7 @@ public override async Task Enable() /// A task that represents the asynchronous operation. public override async Task Disable() { - await adapter.Disable(); + await adapter.Disable().ConfigureAwait(false); } /// @@ -65,7 +65,7 @@ public override async Task Disable() /// A task that represents the asynchronous operation. public override async Task Clear() { - await adapter.Clear(); + await adapter.Clear().ConfigureAwait(false); } private void OnAdapterEntryAdded(object sender, Log.EntryAddedEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v85/V85Network.cs b/dotnet/src/webdriver/DevTools/v85/V85Network.cs index 97e4b4f87d6d8..29bf8f492f4c1 100644 --- a/dotnet/src/webdriver/DevTools/v85/V85Network.cs +++ b/dotnet/src/webdriver/DevTools/v85/V85Network.cs @@ -52,7 +52,7 @@ public V85Network(NetworkAdapter network, FetchAdapter fetch) /// A task that represents the asynchronous operation. public override async Task DisableNetworkCaching() { - await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = true }); + await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = true }).ConfigureAwait(false); } /// @@ -61,7 +61,7 @@ public override async Task DisableNetworkCaching() /// A task that represents the asynchronous operation. public override async Task EnableNetworkCaching() { - await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = false }); + await network.SetCacheDisabled(new SetCacheDisabledCommandSettings() { CacheDisabled = false }).ConfigureAwait(false); } /// @@ -70,7 +70,7 @@ public override async Task EnableNetworkCaching() /// A task that represents the asynchronous operation. public override async Task EnableNetwork() { - await network.Enable(new Network.EnableCommandSettings()); + await network.Enable(new Network.EnableCommandSettings()).ConfigureAwait(false); } /// @@ -79,7 +79,7 @@ public override async Task EnableNetwork() /// A task that represents the asynchronous operation. public override async Task DisableNetwork() { - await network.Disable(); + await network.Disable().ConfigureAwait(false); } /// @@ -88,15 +88,15 @@ public override async Task DisableNetwork() /// A task that represents the asynchronous operation. public override async Task EnableFetchForAllPatterns() { - await fetch.Enable(new OpenQA.Selenium.DevTools.V85.Fetch.EnableCommandSettings() + await fetch.Enable(new Fetch.EnableCommandSettings() { - Patterns = new OpenQA.Selenium.DevTools.V85.Fetch.RequestPattern[] + Patterns = new Fetch.RequestPattern[] { - new OpenQA.Selenium.DevTools.V85.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request }, - new OpenQA.Selenium.DevTools.V85.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response } + new Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request }, + new Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response } }, HandleAuthRequests = true - }); + }).ConfigureAwait(false); } /// @@ -105,7 +105,7 @@ await fetch.Enable(new OpenQA.Selenium.DevTools.V85.Fetch.EnableCommandSettings( /// A task that represents the asynchronous operation. public override async Task DisableFetch() { - await fetch.Disable(); + await fetch.Disable().ConfigureAwait(false); } /// @@ -120,7 +120,7 @@ await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() UserAgent = userAgent.UserAgentString, AcceptLanguage = userAgent.AcceptLanguage, Platform = userAgent.Platform - }); + }).ConfigureAwait(false); } /// @@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData) commandSettings.PostData = Convert.ToBase64String(Encoding.UTF8.GetBytes(requestData.PostData)); } - await fetch.ContinueRequest(commandSettings); + await fetch.ContinueRequest(commandSettings).ConfigureAwait(false); } /// @@ -191,7 +191,7 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa commandSettings.Body = Convert.ToBase64String(Encoding.UTF8.GetBytes(responseData.Body)); } - await fetch.FulfillRequest(commandSettings); + await fetch.FulfillRequest(commandSettings).ConfigureAwait(false); } /// @@ -201,7 +201,7 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa /// A task that represents the asynchronous operation. public override async Task ContinueRequestWithoutModification(HttpRequestData requestData) { - await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }); + await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }).ConfigureAwait(false); } /// @@ -222,7 +222,7 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() Username = userName, Password = password } - }); + }).ConfigureAwait(false); } /// @@ -235,11 +235,11 @@ public override async Task CancelAuth(string requestId) await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() { RequestId = requestId, - AuthChallengeResponse = new OpenQA.Selenium.DevTools.V85.Fetch.AuthChallengeResponse() + AuthChallengeResponse = new Fetch.AuthChallengeResponse() { Response = V85.Fetch.AuthChallengeResponseResponseValues.CancelAuth } - }); + }).ConfigureAwait(false); } /// @@ -252,7 +252,7 @@ public override async Task AddResponseBody(HttpResponseData responseData) // If the response is a redirect, retrieving the body will throw an error in CDP. if (responseData.StatusCode < 300 || responseData.StatusCode > 399) { - var bodyResponse = await fetch.GetResponseBody(new Fetch.GetResponseBodyCommandSettings() { RequestId = responseData.RequestId }); + var bodyResponse = await fetch.GetResponseBody(new Fetch.GetResponseBodyCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); if (bodyResponse.Base64Encoded) { responseData.Body = Encoding.UTF8.GetString(Convert.FromBase64String(bodyResponse.Body)); @@ -271,7 +271,7 @@ public override async Task AddResponseBody(HttpResponseData responseData) /// A task that represents the asynchronous operation. public override async Task ContinueResponseWithoutModification(HttpResponseData responseData) { - await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = responseData.RequestId }); + await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); } private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) diff --git a/dotnet/src/webdriver/DevTools/v85/V85Target.cs b/dotnet/src/webdriver/DevTools/v85/V85Target.cs index 933c525c2bd68..02a3b114bcd1d 100644 --- a/dotnet/src/webdriver/DevTools/v85/V85Target.cs +++ b/dotnet/src/webdriver/DevTools/v85/V85Target.cs @@ -53,7 +53,7 @@ public V85Target(TargetAdapter adapter) public override async Task> GetTargets(Object settings = null) { List targets = new List(); - var response = await adapter.GetTargets(); + var response = await adapter.GetTargets().ConfigureAwait(false); for (int i = 0; i < response.TargetInfos.Length; i++) { var targetInfo = response.TargetInfos[i]; @@ -83,7 +83,7 @@ public override async Task> GetTargets(Object set /// public override async Task AttachToTarget(string targetId) { - var result = await adapter.AttachToTarget(new AttachToTargetCommandSettings() { TargetId = targetId, Flatten = true }); + var result = await adapter.AttachToTarget(new AttachToTargetCommandSettings() { TargetId = targetId, Flatten = true }).ConfigureAwait(false); return result.SessionId; } @@ -99,7 +99,7 @@ await adapter.DetachFromTarget(new DetachFromTargetCommandSettings() { SessionId = sessionId, TargetId = targetId - }); + }).ConfigureAwait(false); } /// @@ -108,7 +108,7 @@ await adapter.DetachFromTarget(new DetachFromTargetCommandSettings() /// A task that represents the asynchronous operation. public override async Task SetAutoAttach() { - await adapter.SetAutoAttach(new SetAutoAttachCommandSettings() { AutoAttach = true, WaitForDebuggerOnStart = false, Flatten = true }); + await adapter.SetAutoAttach(new SetAutoAttachCommandSettings() { AutoAttach = true, WaitForDebuggerOnStart = false, Flatten = true }).ConfigureAwait(false); } private void OnDetachedFromTarget(object sender, DetachedFromTargetEventArgs e) diff --git a/dotnet/src/webdriver/JavaScriptEngine.cs b/dotnet/src/webdriver/JavaScriptEngine.cs index 6570b259ca4ea..f460463fea723 100644 --- a/dotnet/src/webdriver/JavaScriptEngine.cs +++ b/dotnet/src/webdriver/JavaScriptEngine.cs @@ -117,7 +117,7 @@ public async Task StartEventMonitoring() this.session.Value.Domains.JavaScript.BindingCalled += OnScriptBindingCalled; this.session.Value.Domains.JavaScript.ExceptionThrown += OnJavaScriptExceptionThrown; this.session.Value.Domains.JavaScript.ConsoleApiCalled += OnConsoleApiCalled; - await this.EnableDomains(); + await this.EnableDomains().ConfigureAwait(false); } /// @@ -138,10 +138,10 @@ public async Task EnableDomMutationMonitoring() { // Execute the script to have it enabled on the currently loaded page. string script = GetMutationListenerScript(); - await this.session.Value.Domains.JavaScript.Evaluate(script); + await this.session.Value.Domains.JavaScript.Evaluate(script).ConfigureAwait(false); - await this.AddScriptCallbackBinding(MonitorBindingName); - await this.AddInitializationScript(MonitorBindingName, script); + await this.AddScriptCallbackBinding(MonitorBindingName).ConfigureAwait(false); + await this.AddInitializationScript(MonitorBindingName, script).ConfigureAwait(false); } /// @@ -150,8 +150,8 @@ public async Task EnableDomMutationMonitoring() /// A task that represents the asynchronous operation. public async Task DisableDomMutationMonitoring() { - await this.RemoveScriptCallbackBinding(MonitorBindingName); - await this.RemoveInitializationScript(MonitorBindingName); + await this.RemoveScriptCallbackBinding(MonitorBindingName).ConfigureAwait(false); + await this.RemoveInitializationScript(MonitorBindingName).ConfigureAwait(false); } /// @@ -167,9 +167,9 @@ public async Task AddInitializationScript(string scriptNam return this.initializationScripts[scriptName]; } - await this.EnableDomains(); + await this.EnableDomains().ConfigureAwait(false); - string scriptId = await this.session.Value.Domains.JavaScript.AddScriptToEvaluateOnNewDocument(script); + string scriptId = await this.session.Value.Domains.JavaScript.AddScriptToEvaluateOnNewDocument(script).ConfigureAwait(false); InitializationScript initializationScript = new InitializationScript() { ScriptId = scriptId, @@ -191,7 +191,7 @@ public async Task RemoveInitializationScript(string scriptName) if (this.initializationScripts.ContainsKey(scriptName)) { string scriptId = this.initializationScripts[scriptName].ScriptId; - await this.session.Value.Domains.JavaScript.RemoveScriptToEvaluateOnNewDocument(scriptId); + await this.session.Value.Domains.JavaScript.RemoveScriptToEvaluateOnNewDocument(scriptId).ConfigureAwait(false); this.initializationScripts.Remove(scriptName); } } @@ -207,7 +207,7 @@ public async Task ClearInitializationScripts() List scriptNames = new List(this.initializationScripts.Keys); foreach (string scriptName in scriptNames) { - await this.RemoveInitializationScript(scriptName); + await this.RemoveInitializationScript(scriptName).ConfigureAwait(false); } } @@ -222,9 +222,9 @@ public async Task PinScript(string script) // We do an "Evaluate" first so as to immediately create the script on the loaded // page, then will add it to the initialization of future pages. PinnedScript pinnedScript = new PinnedScript(script); - await this.EnableDomains(); - await this.session.Value.Domains.JavaScript.Evaluate(pinnedScript.CreationScript); - pinnedScript.ScriptId = await this.session.Value.Domains.JavaScript.AddScriptToEvaluateOnNewDocument(pinnedScript.CreationScript); + await this.EnableDomains().ConfigureAwait(false); + await this.session.Value.Domains.JavaScript.Evaluate(pinnedScript.CreationScript).ConfigureAwait(false); + pinnedScript.ScriptId = await this.session.Value.Domains.JavaScript.AddScriptToEvaluateOnNewDocument(pinnedScript.CreationScript).ConfigureAwait(false); this.pinnedScripts[pinnedScript.Handle] = pinnedScript; return pinnedScript; } @@ -238,8 +238,8 @@ public async Task UnpinScript(PinnedScript script) { if (this.pinnedScripts.ContainsKey(script.Handle)) { - await this.session.Value.Domains.JavaScript.Evaluate(script.RemovalScript); - await this.session.Value.Domains.JavaScript.RemoveScriptToEvaluateOnNewDocument(script.ScriptId); + await this.session.Value.Domains.JavaScript.Evaluate(script.RemovalScript).ConfigureAwait(false); + await this.session.Value.Domains.JavaScript.RemoveScriptToEvaluateOnNewDocument(script.ScriptId).ConfigureAwait(false); this.pinnedScripts.Remove(script.Handle); } } @@ -257,8 +257,8 @@ public async Task AddScriptCallbackBinding(string bindingName) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "A binding named {0} has already been added", bindingName)); } - await this.EnableDomains(); - await this.session.Value.Domains.JavaScript.AddBinding(bindingName); + await this.EnableDomains().ConfigureAwait(false); + await this.session.Value.Domains.JavaScript.AddBinding(bindingName).ConfigureAwait(false); } /// @@ -268,7 +268,7 @@ public async Task AddScriptCallbackBinding(string bindingName) /// A task that represents the asynchronous operation. public async Task RemoveScriptCallbackBinding(string bindingName) { - await this.session.Value.Domains.JavaScript.RemoveBinding(bindingName); + await this.session.Value.Domains.JavaScript.RemoveBinding(bindingName).ConfigureAwait(false); this.bindings.Remove(bindingName); } @@ -283,7 +283,7 @@ public async Task ClearScriptCallbackBindings() List bindingList = new List(this.bindings); foreach (string binding in bindingList) { - await this.RemoveScriptCallbackBinding(binding); + await this.RemoveScriptCallbackBinding(binding).ConfigureAwait(false); } } @@ -295,9 +295,9 @@ public async Task ClearScriptCallbackBindings() /// A task that represents the asynchronous operation. public async Task ClearAll() { - await this.ClearPinnedScripts(); - await this.ClearInitializationScripts(); - await this.ClearScriptCallbackBindings(); + await this.ClearPinnedScripts().ConfigureAwait(false); + await this.ClearInitializationScripts().ConfigureAwait(false); + await this.ClearScriptCallbackBindings().ConfigureAwait(false); } /// @@ -309,7 +309,7 @@ public async Task ClearAll() public async Task Reset() { this.StopEventMonitoring(); - await ClearAll(); + await ClearAll().ConfigureAwait(false); } /// @@ -347,7 +347,7 @@ private async Task ClearPinnedScripts() List scriptHandles = new List(this.pinnedScripts.Keys); foreach (string scriptHandle in scriptHandles) { - await this.UnpinScript(this.pinnedScripts[scriptHandle]); + await this.UnpinScript(this.pinnedScripts[scriptHandle]).ConfigureAwait(false); } } @@ -355,8 +355,8 @@ private async Task EnableDomains() { if (!this.isEnabled) { - await this.session.Value.Domains.JavaScript.EnablePage(); - await this.session.Value.Domains.JavaScript.EnableRuntime(); + await this.session.Value.Domains.JavaScript.EnablePage().ConfigureAwait(false); + await this.session.Value.Domains.JavaScript.EnableRuntime().ConfigureAwait(false); this.isEnabled = true; } } diff --git a/dotnet/src/webdriver/NetworkManager.cs b/dotnet/src/webdriver/NetworkManager.cs index 7bce452bcb4af..cb26932cad761 100644 --- a/dotnet/src/webdriver/NetworkManager.cs +++ b/dotnet/src/webdriver/NetworkManager.cs @@ -73,9 +73,9 @@ public async Task StartMonitoring() this.session.Value.Domains.Network.RequestPaused += OnRequestPaused; this.session.Value.Domains.Network.AuthRequired += OnAuthRequired; this.session.Value.Domains.Network.ResponsePaused += OnResponsePaused; - await this.session.Value.Domains.Network.EnableFetchForAllPatterns(); - await this.session.Value.Domains.Network.EnableNetwork(); - await this.session.Value.Domains.Network.DisableNetworkCaching(); + await this.session.Value.Domains.Network.EnableFetchForAllPatterns().ConfigureAwait(false); + await this.session.Value.Domains.Network.EnableNetwork().ConfigureAwait(false); + await this.session.Value.Domains.Network.DisableNetworkCaching().ConfigureAwait(false); } /// @@ -87,7 +87,7 @@ public async Task StopMonitoring() this.session.Value.Domains.Network.ResponsePaused -= OnResponsePaused; this.session.Value.Domains.Network.AuthRequired -= OnAuthRequired; this.session.Value.Domains.Network.RequestPaused -= OnRequestPaused; - await this.session.Value.Domains.Network.EnableNetworkCaching(); + await this.session.Value.Domains.Network.EnableNetworkCaching().ConfigureAwait(false); } /// @@ -200,7 +200,7 @@ private async Task OnAuthRequired(object sender, AuthRequiredEventArgs e) if (authenticationHandler.UriMatcher.Invoke(uri)) { PasswordCredentials credentials = authenticationHandler.Credentials as PasswordCredentials; - await this.session.Value.Domains.Network.ContinueWithAuth(e.RequestId, credentials.UserName, credentials.Password); + await this.session.Value.Domains.Network.ContinueWithAuth(e.RequestId, credentials.UserName, credentials.Password).ConfigureAwait(false); successfullyAuthenticated = true; break; } @@ -208,7 +208,7 @@ private async Task OnAuthRequired(object sender, AuthRequiredEventArgs e) if (!successfullyAuthenticated) { - await this.session.Value.Domains.Network.CancelAuth(e.RequestId); + await this.session.Value.Domains.Network.CancelAuth(e.RequestId).ConfigureAwait(false); } } @@ -225,19 +225,19 @@ private async Task OnRequestPaused(object sender, RequestPausedEventArgs e) { if (handler.RequestTransformer != null) { - await this.session.Value.Domains.Network.ContinueRequest(handler.RequestTransformer(e.RequestData)); + await this.session.Value.Domains.Network.ContinueRequest(handler.RequestTransformer(e.RequestData)).ConfigureAwait(false); return; } if (handler.ResponseSupplier != null) { - await this.session.Value.Domains.Network.ContinueRequestWithResponse(e.RequestData, handler.ResponseSupplier(e.RequestData)); + await this.session.Value.Domains.Network.ContinueRequestWithResponse(e.RequestData, handler.ResponseSupplier(e.RequestData)).ConfigureAwait(false); return; } } } - await this.session.Value.Domains.Network.ContinueRequestWithoutModification(e.RequestData); + await this.session.Value.Domains.Network.ContinueRequestWithoutModification(e.RequestData).ConfigureAwait(false); } private async Task OnResponsePaused(object sender, ResponsePausedEventArgs e) @@ -245,7 +245,7 @@ private async Task OnResponsePaused(object sender, ResponsePausedEventArgs e) if (e.ResponseData.Headers.Count > 0) { // If no headers are present, the body cannot be retrieved. - await this.session.Value.Domains.Network.AddResponseBody(e.ResponseData); + await this.session.Value.Domains.Network.AddResponseBody(e.ResponseData).ConfigureAwait(false); } if (this.NetworkResponseReceived != null) @@ -262,12 +262,12 @@ private async Task OnResponsePaused(object sender, ResponsePausedEventArgs e) // It might be better to refactor that method signature to simply pass the request ID, or // alternatively, just pass the response data, which should also contain the request ID anyway. HttpRequestData requestData = new HttpRequestData() { RequestId = e.ResponseData.RequestId }; - await this.session.Value.Domains.Network.ContinueRequestWithResponse(requestData, handler.ResponseTransformer(e.ResponseData)); + await this.session.Value.Domains.Network.ContinueRequestWithResponse(requestData, handler.ResponseTransformer(e.ResponseData)).ConfigureAwait(false); return; } } - await this.session.Value.Domains.Network.ContinueResponseWithoutModification(e.ResponseData); + await this.session.Value.Domains.Network.ContinueResponseWithoutModification(e.ResponseData).ConfigureAwait(false); } } } diff --git a/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs b/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs index aaea34ae35d04..0b69c9dccf05b 100644 --- a/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs +++ b/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs @@ -177,15 +177,7 @@ public virtual Response Execute(Command commandToExecute) HttpResponseInfo responseInfo = null; try { - // Use TaskFactory to avoid deadlock in multithreaded implementations. - responseInfo = new TaskFactory(CancellationToken.None, - TaskCreationOptions.None, - TaskContinuationOptions.None, - TaskScheduler.Default) - .StartNew(() => this.MakeHttpRequest(requestInfo)) - .Unwrap() - .GetAwaiter() - .GetResult(); + responseInfo = Task.Run(async () => await this.MakeHttpRequest(requestInfo)).GetAwaiter().GetResult(); } catch (HttpRequestException ex) { @@ -278,10 +270,10 @@ private async Task MakeHttpRequest(HttpRequestInfo requestInfo requestMessage.Content.Headers.ContentType = contentTypeHeader; } - using (HttpResponseMessage responseMessage = await this.client.SendAsync(requestMessage)) + using (HttpResponseMessage responseMessage = await this.client.SendAsync(requestMessage).ConfigureAwait(false)) { HttpResponseInfo httpResponseInfo = new HttpResponseInfo(); - httpResponseInfo.Body = await responseMessage.Content.ReadAsStringAsync(); + httpResponseInfo.Body = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); httpResponseInfo.ContentType = responseMessage.Content.Headers.ContentType?.ToString(); httpResponseInfo.StatusCode = responseMessage.StatusCode; From d1a59128b785ffa5d76a4a11b4663250f52197a1 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 8 Sep 2023 15:06:49 +0300 Subject: [PATCH 051/141] [dotnet] Update cdp default command timeout in inline docs (#12707) --- dotnet/src/webdriver/DevTools/DevToolsSession.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/src/webdriver/DevTools/DevToolsSession.cs b/dotnet/src/webdriver/DevTools/DevToolsSession.cs index 58b97e7961181..da03bd4860dfa 100644 --- a/dotnet/src/webdriver/DevTools/DevToolsSession.cs +++ b/dotnet/src/webdriver/DevTools/DevToolsSession.cs @@ -86,7 +86,7 @@ public DevToolsSession(string endpointAddress) public event EventHandler DevToolsEventReceived; /// - /// Gets or sets the time to wait for a command to complete. Default is 5 seconds. + /// Gets or sets the time to wait for a command to complete. Default is 30 seconds. /// public TimeSpan CommandTimeout { get; set; } From 1054775f2f10dfe3f7201498bdf10b7d7d695cba Mon Sep 17 00:00:00 2001 From: Krishna Suravarapu <36037520+KrishnaSuravarapu@users.noreply.github.com> Date: Sat, 9 Sep 2023 03:09:16 +0530 Subject: [PATCH 052/141] [java] Fix NewSession Runner (#12700) Chore: Changing while to if Co-authored-by: Diego Molina --- .../grid/distributor/local/LocalDistributor.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java b/java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java index 5d9fff18cb070..3b147de61b429 100644 --- a/java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java +++ b/java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java @@ -756,18 +756,20 @@ private class NewSessionRunnable implements Runnable { @Override public void run() { Set inQueue; - boolean loop; + boolean pollQueue; + if (rejectUnsupportedCaps) { inQueue = sessionQueue.getQueueContents().stream() .map(SessionRequestCapability::getRequestId) .collect(Collectors.toSet()); - loop = !inQueue.isEmpty(); + pollQueue = !inQueue.isEmpty(); } else { inQueue = null; - loop = !sessionQueue.peekEmpty(); + pollQueue = !sessionQueue.peekEmpty(); } - while (loop) { + + if (pollQueue) { // We deliberately run this outside of a lock: if we're unsuccessful // starting the session, we just put the request back on the queue. // This does mean, however, that under high contention, we might end @@ -783,11 +785,9 @@ public void run() { List matchingRequests = sessionQueue.getNextAvailable(stereotypes); matchingRequests.forEach( req -> sessionCreatorExecutor.execute(() -> handleNewSessionRequest(req))); - loop = !matchingRequests.isEmpty(); - } else { - loop = false; } } + if (rejectUnsupportedCaps) { checkMatchingSlot( sessionQueue.getQueueContents().stream() From 8add57871e6bed306f84e70150d1b8c18e3868b7 Mon Sep 17 00:00:00 2001 From: Scott Babcock Date: Fri, 8 Sep 2023 15:55:54 -0700 Subject: [PATCH 053/141] Add 'getArray' method for array values (#12703) Co-authored-by: Diego Molina --- .../openqa/selenium/grid/config/Config.java | 18 ++++++++++ .../selenium/grid/config/JsonConfigTest.java | 34 ++++++++++++++++++ .../selenium/grid/config/MapConfigTest.java | 35 +++++++++++++++++++ .../selenium/grid/config/TomlConfigTest.java | 25 +++++++++++++ 4 files changed, 112 insertions(+) diff --git a/java/src/org/openqa/selenium/grid/config/Config.java b/java/src/org/openqa/selenium/grid/config/Config.java index 16a8dee74cdfb..2c83d621e6005 100644 --- a/java/src/org/openqa/selenium/grid/config/Config.java +++ b/java/src/org/openqa/selenium/grid/config/Config.java @@ -18,6 +18,7 @@ package org.openqa.selenium.grid.config; import com.google.common.collect.ImmutableList; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -46,6 +47,23 @@ default Optional getBool(String section, String option) { return get(section, option).map(Boolean::parseBoolean); } + default Optional>> getArray(String section, String option) { + Optional> flatConfigs = getAll(section, option); + if (!flatConfigs.isPresent()) return Optional.empty(); + + List configItem = new ArrayList<>(); + List> configList = new ArrayList<>(); + for (String next : flatConfigs.get()) { + if (Config.DELIMITER.equals(next)) { + configList.add(configItem); + configItem = new ArrayList<>(); + } else { + configItem.add(next); + } + } + return Optional.of(configList); + } + default X getClass(String section, String option, Class typeOfClass, String defaultClazz) { String clazz = get(section, option).orElse(defaultClazz); diff --git a/java/test/org/openqa/selenium/grid/config/JsonConfigTest.java b/java/test/org/openqa/selenium/grid/config/JsonConfigTest.java index 1555af4be249c..289cd977e2e34 100644 --- a/java/test/org/openqa/selenium/grid/config/JsonConfigTest.java +++ b/java/test/org/openqa/selenium/grid/config/JsonConfigTest.java @@ -125,4 +125,38 @@ void ensureCanReadListOfMaps() { Optional> content = config.getAll("node", "driver-configuration"); assertThat(content).isEqualTo(Optional.of(expected)); } + + @Test + void ensureCanReadListOfLists() { + String raw = + String.join( + "", + "", + "{", + "`cheeses`: {", + "`default`: `manchego`,", + "`type`: [", + "{", + "`name`: `soft cheese`,", + "`default`: `brie`", + "},", + "{", + "`name`: `Medium-hard cheese`,", + "`default`: `Emmental`", + "}", + "]", + "}", + "}") + .replace("`", "\""); + Config config = new JsonConfig(new StringReader(raw)); + + List> expected = + Arrays.asList( + Arrays.asList("name=\"soft cheese\"", "default=\"brie\""), + Arrays.asList("name=\"Medium-hard cheese\"", "default=\"Emmental\"")); + assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList())) + .isEqualTo(expected); + assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList()).subList(0, 1)) + .isEqualTo(expected.subList(0, 1)); + } } diff --git a/java/test/org/openqa/selenium/grid/config/MapConfigTest.java b/java/test/org/openqa/selenium/grid/config/MapConfigTest.java index 230f9f2cfb71e..714e3fe0d2747 100644 --- a/java/test/org/openqa/selenium/grid/config/MapConfigTest.java +++ b/java/test/org/openqa/selenium/grid/config/MapConfigTest.java @@ -132,4 +132,39 @@ void ensureCanReadListOfMaps() { Optional> content = config.getAll("node", "driver-configuration"); assertThat(content).isEqualTo(Optional.of(expected)); } + + @Test + void ensureCanReadListOfLists() { + String json = + String.join( + "", + "", + "{", + "`cheeses`: {", + "`default`: `manchego`,", + "`type`: [", + "{", + "`name`: `soft cheese`,", + "`default`: `brie`", + "},", + "{", + "`name`: `Medium-hard cheese`,", + "`default`: `Emmental`", + "}", + "]", + "}", + "}") + .replace("`", "\""); + Map raw = new Json().toType(json, MAP_TYPE); + Config config = new MapConfig(raw); + + List> expected = + Arrays.asList( + Arrays.asList("name=\"soft cheese\"", "default=\"brie\""), + Arrays.asList("name=\"Medium-hard cheese\"", "default=\"Emmental\"")); + assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList())) + .isEqualTo(expected); + assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList()).subList(0, 1)) + .isEqualTo(expected.subList(0, 1)); + } } diff --git a/java/test/org/openqa/selenium/grid/config/TomlConfigTest.java b/java/test/org/openqa/selenium/grid/config/TomlConfigTest.java index f96ed1543059e..f4a093ff08df3 100644 --- a/java/test/org/openqa/selenium/grid/config/TomlConfigTest.java +++ b/java/test/org/openqa/selenium/grid/config/TomlConfigTest.java @@ -98,4 +98,29 @@ void ensureCanReadListOfMaps() { Optional> content = config.getAll("node", "driver-configuration"); assertThat(content).isEqualTo(Optional.of(expected)); } + + @Test + void ensureCanReadListOfLists() { + String[] rawConfig = + new String[] { + "[cheeses]", + "default = manchego", + "[[cheeses.type]]", + "name = \"soft cheese\"", + "default = \"brie\"", + "[[cheeses.type]]", + "name = \"Medium-hard cheese\"", + "default = \"Emmental\"" + }; + Config config = new TomlConfig(new StringReader(String.join("\n", rawConfig))); + + List> expected = + Arrays.asList( + Arrays.asList("default=\"brie\"", "name=\"soft cheese\""), + Arrays.asList("default=\"Emmental\"", "name=\"Medium-hard cheese\"")); + assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList())) + .isEqualTo(expected); + assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList()).subList(0, 1)) + .isEqualTo(expected.subList(0, 1)); + } } From 5f3f7d096a75700e055effbe13cbc22117014e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sautter?= Date: Sat, 9 Sep 2023 14:25:34 +0200 Subject: [PATCH 054/141] [grid] ensure we do not close HttpClients waiting for responses --- java/src/org/openqa/selenium/grid/router/HandleSession.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/grid/router/HandleSession.java b/java/src/org/openqa/selenium/grid/router/HandleSession.java index 87dedfa176a60..fc66b4c8a5fd6 100644 --- a/java/src/org/openqa/selenium/grid/router/HandleSession.java +++ b/java/src/org/openqa/selenium/grid/router/HandleSession.java @@ -73,7 +73,9 @@ class HandleSession implements HttpHandler { this.httpClients = CacheBuilder.newBuilder() - .expireAfterAccess(Duration.ofMinutes(1)) + // this timeout must be bigger than default connection + read timeout, to ensure we do + // not close HttpClients which might have requests waiting for responses + .expireAfterAccess(Duration.ofMinutes(4)) .removalListener( (RemovalListener) removal -> removal.getValue().close()) .build(); From 73da1e8bcad94eb147c195a57a0daea5ee638434 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sun, 10 Sep 2023 11:24:52 -0500 Subject: [PATCH 055/141] [java] fix bug for overwriting log output stream passed in by user. --- java/src/org/openqa/selenium/remote/service/DriverService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/remote/service/DriverService.java b/java/src/org/openqa/selenium/remote/service/DriverService.java index 43dc4c2edc0d9..a34f594e5ff1a 100644 --- a/java/src/org/openqa/selenium/remote/service/DriverService.java +++ b/java/src/org/openqa/selenium/remote/service/DriverService.java @@ -452,7 +452,7 @@ protected OutputStream getLogOutput() { } protected void parseLogOutput(String logProperty) { - if (getLogFile() != null) { + if (getLogFile() != null || logOutputStream != null) { return; } From 0658f862f3a268babce5efef089315978271a90f Mon Sep 17 00:00:00 2001 From: AutomatedTester Date: Mon, 11 Sep 2023 13:28:42 +0530 Subject: [PATCH 056/141] [build] bump rules_python to 0.25.0 --- WORKSPACE | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index cedf3a9abbbd0..9bd7e9a79aa93 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -35,11 +35,12 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() + http_archive( name = "rules_python", - sha256 = "0a8003b044294d7840ac7d9d73eef05d6ceb682d7516781a4ec62eeb34702578", - strip_prefix = "rules_python-0.24.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.24.0/rules_python-0.24.0.tar.gz", + sha256 = "5868e73107a8e85d8f323806e60cad7283f34b32163ea6ff1020cf27abef6036", + strip_prefix = "rules_python-0.25.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.25.0/rules_python-0.25.0.tar.gz", ) load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_multi_toolchains") From 2fa6d03d6fc0579c7a578bfc27784df16c7b2433 Mon Sep 17 00:00:00 2001 From: Simon Mavi Stewart Date: Mon, 11 Sep 2023 10:12:17 +0100 Subject: [PATCH 057/141] Run format script. No logical changes --- WORKSPACE | 1 - .../selenium/grid/config/JsonConfigTest.java | 48 +++++++++---------- .../selenium/grid/config/MapConfigTest.java | 48 +++++++++---------- .../selenium/grid/config/TomlConfigTest.java | 30 ++++++------ 4 files changed, 63 insertions(+), 64 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 9bd7e9a79aa93..5b3a6c35a6927 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -35,7 +35,6 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() - http_archive( name = "rules_python", sha256 = "5868e73107a8e85d8f323806e60cad7283f34b32163ea6ff1020cf27abef6036", diff --git a/java/test/org/openqa/selenium/grid/config/JsonConfigTest.java b/java/test/org/openqa/selenium/grid/config/JsonConfigTest.java index 289cd977e2e34..4312866b8fc7b 100644 --- a/java/test/org/openqa/selenium/grid/config/JsonConfigTest.java +++ b/java/test/org/openqa/selenium/grid/config/JsonConfigTest.java @@ -129,34 +129,34 @@ void ensureCanReadListOfMaps() { @Test void ensureCanReadListOfLists() { String raw = - String.join( - "", - "", - "{", - "`cheeses`: {", - "`default`: `manchego`,", - "`type`: [", - "{", - "`name`: `soft cheese`,", - "`default`: `brie`", - "},", - "{", - "`name`: `Medium-hard cheese`,", - "`default`: `Emmental`", - "}", - "]", - "}", - "}") - .replace("`", "\""); + String.join( + "", + "", + "{", + "`cheeses`: {", + "`default`: `manchego`,", + "`type`: [", + "{", + "`name`: `soft cheese`,", + "`default`: `brie`", + "},", + "{", + "`name`: `Medium-hard cheese`,", + "`default`: `Emmental`", + "}", + "]", + "}", + "}") + .replace("`", "\""); Config config = new JsonConfig(new StringReader(raw)); List> expected = - Arrays.asList( - Arrays.asList("name=\"soft cheese\"", "default=\"brie\""), - Arrays.asList("name=\"Medium-hard cheese\"", "default=\"Emmental\"")); + Arrays.asList( + Arrays.asList("name=\"soft cheese\"", "default=\"brie\""), + Arrays.asList("name=\"Medium-hard cheese\"", "default=\"Emmental\"")); assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList())) - .isEqualTo(expected); + .isEqualTo(expected); assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList()).subList(0, 1)) - .isEqualTo(expected.subList(0, 1)); + .isEqualTo(expected.subList(0, 1)); } } diff --git a/java/test/org/openqa/selenium/grid/config/MapConfigTest.java b/java/test/org/openqa/selenium/grid/config/MapConfigTest.java index 714e3fe0d2747..bef5317b4ab68 100644 --- a/java/test/org/openqa/selenium/grid/config/MapConfigTest.java +++ b/java/test/org/openqa/selenium/grid/config/MapConfigTest.java @@ -136,35 +136,35 @@ void ensureCanReadListOfMaps() { @Test void ensureCanReadListOfLists() { String json = - String.join( - "", - "", - "{", - "`cheeses`: {", - "`default`: `manchego`,", - "`type`: [", - "{", - "`name`: `soft cheese`,", - "`default`: `brie`", - "},", - "{", - "`name`: `Medium-hard cheese`,", - "`default`: `Emmental`", - "}", - "]", - "}", - "}") - .replace("`", "\""); + String.join( + "", + "", + "{", + "`cheeses`: {", + "`default`: `manchego`,", + "`type`: [", + "{", + "`name`: `soft cheese`,", + "`default`: `brie`", + "},", + "{", + "`name`: `Medium-hard cheese`,", + "`default`: `Emmental`", + "}", + "]", + "}", + "}") + .replace("`", "\""); Map raw = new Json().toType(json, MAP_TYPE); Config config = new MapConfig(raw); List> expected = - Arrays.asList( - Arrays.asList("name=\"soft cheese\"", "default=\"brie\""), - Arrays.asList("name=\"Medium-hard cheese\"", "default=\"Emmental\"")); + Arrays.asList( + Arrays.asList("name=\"soft cheese\"", "default=\"brie\""), + Arrays.asList("name=\"Medium-hard cheese\"", "default=\"Emmental\"")); assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList())) - .isEqualTo(expected); + .isEqualTo(expected); assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList()).subList(0, 1)) - .isEqualTo(expected.subList(0, 1)); + .isEqualTo(expected.subList(0, 1)); } } diff --git a/java/test/org/openqa/selenium/grid/config/TomlConfigTest.java b/java/test/org/openqa/selenium/grid/config/TomlConfigTest.java index f4a093ff08df3..2de672f07d78e 100644 --- a/java/test/org/openqa/selenium/grid/config/TomlConfigTest.java +++ b/java/test/org/openqa/selenium/grid/config/TomlConfigTest.java @@ -102,25 +102,25 @@ void ensureCanReadListOfMaps() { @Test void ensureCanReadListOfLists() { String[] rawConfig = - new String[] { - "[cheeses]", - "default = manchego", - "[[cheeses.type]]", - "name = \"soft cheese\"", - "default = \"brie\"", - "[[cheeses.type]]", - "name = \"Medium-hard cheese\"", - "default = \"Emmental\"" - }; + new String[] { + "[cheeses]", + "default = manchego", + "[[cheeses.type]]", + "name = \"soft cheese\"", + "default = \"brie\"", + "[[cheeses.type]]", + "name = \"Medium-hard cheese\"", + "default = \"Emmental\"" + }; Config config = new TomlConfig(new StringReader(String.join("\n", rawConfig))); List> expected = - Arrays.asList( - Arrays.asList("default=\"brie\"", "name=\"soft cheese\""), - Arrays.asList("default=\"Emmental\"", "name=\"Medium-hard cheese\"")); + Arrays.asList( + Arrays.asList("default=\"brie\"", "name=\"soft cheese\""), + Arrays.asList("default=\"Emmental\"", "name=\"Medium-hard cheese\"")); assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList())) - .isEqualTo(expected); + .isEqualTo(expected); assertThat(config.getArray("cheeses", "type").orElse(Collections.emptyList()).subList(0, 1)) - .isEqualTo(expected.subList(0, 1)); + .isEqualTo(expected.subList(0, 1)); } } From c77bd1aa314e385eb89277288760e5d4eb778a50 Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Mon, 11 Sep 2023 11:15:51 +0100 Subject: [PATCH 058/141] Make sure offline sets associated flags (#12718) --- rust/src/main.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index 9db7c072acf35..6278cb10a0955 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -157,17 +157,28 @@ fn main() { flush_and_exit(DATAERR, &log); }; - selenium_manager.set_logger(log); selenium_manager.set_browser_version(cli.browser_version.unwrap_or_default()); selenium_manager.set_driver_version(cli.driver_version.unwrap_or_default()); selenium_manager.set_browser_path(cli.browser_path.unwrap_or_default()); selenium_manager.set_os(cli.os.unwrap_or_default()); selenium_manager.set_arch(cli.arch.unwrap_or_default()); selenium_manager.set_ttl(cli.ttl); - selenium_manager.set_offline(cli.offline); selenium_manager.set_force_browser_download(cli.force_browser_download); selenium_manager.set_avoid_browser_download(cli.avoid_browser_download); selenium_manager.set_cache_path(cache_path.clone()); + selenium_manager.set_offline(cli.offline); + if cli.offline { + if cli.force_browser_download { + log.warn("Offline flag set, but also asked to force downloads. Honouring offline flag"); + } + selenium_manager.set_force_browser_download(false); + if !cli.avoid_browser_download { + log.warn("Offline flag set, but also asked not to avoid browser downloads. Honouring offline flag"); + } + selenium_manager.set_avoid_browser_download(true); + } + selenium_manager.set_logger(log); + if cli.clear_cache || BooleanKey("clear-cache", false).get_value() { clear_cache(selenium_manager.get_logger(), &cache_path); From 02359d369d11b0916e590aa82e8e7f0995c81c4c Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Mon, 11 Sep 2023 12:17:41 +0100 Subject: [PATCH 059/141] [ci] Break RBE into a format and test run step rather than a single lump (#12721) --- .github/workflows/ci-rbe.yml | 8 ++++++++ scripts/github-actions/check-format.sh | 20 ++++++++++++++++++++ scripts/github-actions/ci-build.sh | 15 --------------- 3 files changed, 28 insertions(+), 15 deletions(-) create mode 100755 scripts/github-actions/check-format.sh diff --git a/.github/workflows/ci-rbe.yml b/.github/workflows/ci-rbe.yml index 4f940f9020363..881f67492d254 100644 --- a/.github/workflows/ci-rbe.yml +++ b/.github/workflows/ci-rbe.yml @@ -8,6 +8,14 @@ on: workflow_dispatch: jobs: + format: + name: Format + uses: ./.github/workflows/bazel.yml + with: + name: Check format script run + cache-key: rbe + ruby-version: jruby-9.4.2.0 + run: ./scripts/github-actions/check-format.sh test: name: Test uses: ./.github/workflows/bazel.yml diff --git a/scripts/github-actions/check-format.sh b/scripts/github-actions/check-format.sh new file mode 100755 index 0000000000000..dcd659090d39a --- /dev/null +++ b/scripts/github-actions/check-format.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -eufo pipefail +# We want to see what's going on +set -x + +# The ruby version may have been set by the CI runner. Stash +# changes while we check to see if we need to reformat the +# code. +git config user.email "selenium@example.com" +git config user.name "CI Build" +git commit -am 'Temp commit to allow format to run cleanly' + +# Fail the build if the format script needs to be re-run +./scripts/format.sh +git diff --exit-code + +# Now we're made it out, reapply changes made by the build +# runner +git reset --soft HEAD^ diff --git a/scripts/github-actions/ci-build.sh b/scripts/github-actions/ci-build.sh index f073aab13cd01..6a3c08f195f1d 100755 --- a/scripts/github-actions/ci-build.sh +++ b/scripts/github-actions/ci-build.sh @@ -4,21 +4,6 @@ set -eufo pipefail # We want to see what's going on set -x -# The ruby version may have been set by the CI runner. Stash -# changes while we check to see if we need to reformat the -# code. -git config user.email "selenium@example.com" -git config user.name "CI Build" -git commit -am 'Temp commit to allow format to run cleanly' - -# Fail the build if the format script needs to be re-run -./scripts/format.sh -git diff --exit-code - -# Now we're made it out, reapply changes made by the build -# runner -git reset --soft HEAD^ - # The NPM repository rule wants to write to the HOME directory # but that's configured for the remote build machines, so run # that repository rule first so that the subsequent remote From ce876402e812c5b7a380c7dc38adcb7ece865a91 Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Mon, 11 Sep 2023 13:02:40 +0100 Subject: [PATCH 060/141] [bazel + rust + ci]: Enable rust linting (#12722) --- WORKSPACE | 1 + rust/BUILD.bazel | 6 +++- rust/defs.bzl | 14 ++++++++++ rust/private/BUILD.bazel | 0 rust/private/rustfmt_config.bzl | 10 +++++++ rust/private/rustfmt_wrapper.bzl | 47 ++++++++++++++++++++++++++++++++ rust/src/main.rs | 1 - scripts/format.sh | 4 +++ 8 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 rust/defs.bzl create mode 100644 rust/private/BUILD.bazel create mode 100644 rust/private/rustfmt_config.bzl create mode 100644 rust/private/rustfmt_wrapper.bzl diff --git a/WORKSPACE b/WORKSPACE index 5b3a6c35a6927..40f16067d43c4 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -20,6 +20,7 @@ load("@apple_rules_lint//lint:setup.bzl", "lint_setup") # Add your linters here. lint_setup({ "java-spotbugs": "//java:spotbugs-config", + "rust-rustfmt": "//rust:enable-rustfmt", }) http_archive( diff --git a/rust/BUILD.bazel b/rust/BUILD.bazel index 524ceabfa5e26..e022eff7e40b5 100644 --- a/rust/BUILD.bazel +++ b/rust/BUILD.bazel @@ -1,5 +1,9 @@ load("@crates//:defs.bzl", "all_crate_deps") -load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test", "rust_test_suite") +load("//rust:defs.bzl", "rust_binary", "rust_library", "rust_test", "rust_test_suite", "rustfmt_config") + +rustfmt_config( + name = "enable-rustfmt", +) # We want the release versions of Selenium to include the prebuilt # binaries, but if we're doing day-to-day dev work, then we should diff --git a/rust/defs.bzl b/rust/defs.bzl new file mode 100644 index 0000000000000..b053c9ad8240a --- /dev/null +++ b/rust/defs.bzl @@ -0,0 +1,14 @@ +load( + "//rust/private:rustfmt_wrapper.bzl", + _rust_binary = "rust_binary", + _rust_library = "rust_library", + _rust_test = "rust_test", + _rust_test_suite = "rust_test_suite", +) +load("//rust/private:rustfmt_config.bzl", _rustfmt_config = "rustfmt_config") + +rust_binary = _rust_binary +rust_library = _rust_library +rust_test = _rust_test +rust_test_suite = _rust_test_suite +rustfmt_config = _rustfmt_config diff --git a/rust/private/BUILD.bazel b/rust/private/BUILD.bazel new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/rust/private/rustfmt_config.bzl b/rust/private/rustfmt_config.bzl new file mode 100644 index 0000000000000..6dc17ce659310 --- /dev/null +++ b/rust/private/rustfmt_config.bzl @@ -0,0 +1,10 @@ +RustfmtConfig = provider() + +def _rust_config_impl(ctx): + return [ + RustfmtConfig(), + ] + +rustfmt_config = rule( + _rust_config_impl, +) diff --git a/rust/private/rustfmt_wrapper.bzl b/rust/private/rustfmt_wrapper.bzl new file mode 100644 index 0000000000000..fbaa3bde53c79 --- /dev/null +++ b/rust/private/rustfmt_wrapper.bzl @@ -0,0 +1,47 @@ +load("@apple_rules_lint//lint:defs.bzl", "get_lint_config") +load( + "@rules_rust//rust:defs.bzl", + "rustfmt_test", + _rust_binary = "rust_binary", + _rust_library = "rust_library", + _rust_test = "rust_test", + _rust_test_suite = "rust_test_suite", +) + +def _wrap_with_fmt_test(name, tags): + config = get_lint_config("rust-rustfmt", tags) + if config: + rustfmt_test( + name = "%s-fmt" % name, + targets = [ + ":%s" % name, + ], + tags = [ + "lint", + "rust-rustfmt", + "rustfmt", + ], + ) + +def rust_library(name, **kwargs): + _rust_library(name = name, **kwargs) + _wrap_with_fmt_test(name, kwargs.get("tags", [])) + +def rust_binary(name, **kwargs): + _rust_binary(name = name, **kwargs) + _wrap_with_fmt_test(name, kwargs.get("tags", [])) + +def rust_test(name, **kwargs): + _rust_test(name = name, **kwargs) + _wrap_with_fmt_test(name, kwargs.get("tags", [])) + +def rust_test_suite(name, srcs = [], **kwargs): + _rust_test_suite(name = name, srcs = srcs, **kwargs) + for src in srcs: + if not src.endswith(".rs"): + fail("srcs should have `.rs` extensions") + + # Prefixed with `name` to allow parameterization with macros + # The test name should not end with `.rs` + test_name = name + "_" + src[:-3] + _wrap_with_fmt_test(test_name, kwargs.get("tags", [])) diff --git a/rust/src/main.rs b/rust/src/main.rs index 6278cb10a0955..30197be8a6d9d 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -179,7 +179,6 @@ fn main() { } selenium_manager.set_logger(log); - if cli.clear_cache || BooleanKey("clear-cache", false).get_value() { clear_cache(selenium_manager.get_logger(), &cache_path); } diff --git a/scripts/format.sh b/scripts/format.sh index 00881fd08bfbd..1c62717c827f9 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -15,3 +15,7 @@ bazel run //:buildifier section "Java" echo " google-java-format" >&2 find "$PWD/java" -type f -name '*.java' | xargs "$GOOGLE_JAVA_FORMAT" --replace + +section "Rust" +echo " rustfmt (fix with: bazel run @rules_rust//:rustfmt)" >&2 +bazel test //rust/... --test_tag_filters="rust-rustfmt" --build_tests_only From cd61441a153ef69ea908f0ff8632fdc3414b4beb Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Mon, 11 Sep 2023 14:47:27 +0100 Subject: [PATCH 061/141] [rust] Ensure logger is set first so other setters can use it (#12720) --- rust/src/main.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index 30197be8a6d9d..feb6961ac5715 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -126,7 +126,7 @@ struct Cli { } fn main() { - let cli = Cli::parse(); + let mut cli = Cli::parse(); let cache_path = StringKey(vec![CACHE_PATH_KEY], &cli.cache_path.unwrap_or_default()).get_value(); @@ -157,6 +157,19 @@ fn main() { flush_and_exit(DATAERR, &log); }; + if cli.offline { + if cli.force_browser_download { + log.warn("Offline flag set, but also asked to force downloads. Honouring offline flag"); + } + cli.force_browser_download = false; + if !cli.avoid_browser_download { + log.warn("Offline flag set, but also asked not to avoid browser downloads. Honouring offline flag"); + } + cli.avoid_browser_download = true; + } + + // Logger set first so other setters can use it + selenium_manager.set_logger(log); selenium_manager.set_browser_version(cli.browser_version.unwrap_or_default()); selenium_manager.set_driver_version(cli.driver_version.unwrap_or_default()); selenium_manager.set_browser_path(cli.browser_path.unwrap_or_default()); @@ -167,17 +180,6 @@ fn main() { selenium_manager.set_avoid_browser_download(cli.avoid_browser_download); selenium_manager.set_cache_path(cache_path.clone()); selenium_manager.set_offline(cli.offline); - if cli.offline { - if cli.force_browser_download { - log.warn("Offline flag set, but also asked to force downloads. Honouring offline flag"); - } - selenium_manager.set_force_browser_download(false); - if !cli.avoid_browser_download { - log.warn("Offline flag set, but also asked not to avoid browser downloads. Honouring offline flag"); - } - selenium_manager.set_avoid_browser_download(true); - } - selenium_manager.set_logger(log); if cli.clear_cache || BooleanKey("clear-cache", false).get_value() { clear_cache(selenium_manager.get_logger(), &cache_path); From 493ccb83ab640fe6618438b169711ccfb75dfe9c Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Mon, 11 Sep 2023 18:25:30 +0100 Subject: [PATCH 062/141] Roll pinned browser versions (#12719) Updated the bidi tests, since the `NavigationId` will never by `null` in a bidi navigation event --- common/repositories.bzl | 40 ++++++++------- .../org/openqa/selenium/bidi/BiDiTest.java | 3 +- .../grid/router/RemoteWebDriverBiDiTest.java | 2 +- scripts/pinned_browsers.py | 49 +++++++++++-------- 4 files changed, 53 insertions(+), 41 deletions(-) diff --git a/common/repositories.bzl b/common/repositories.bzl index bbc7b93564d08..0008b1a4cf6ce 100644 --- a/common/repositories.bzl +++ b/common/repositories.bzl @@ -10,8 +10,8 @@ def pin_browsers(): http_archive( name = "linux_firefox", - url = "https://ftp.mozilla.org/pub/firefox/releases/115.0.3/linux-x86_64/en-US/firefox-115.0.3.tar.bz2", - sha256 = "ee8980afe907fa552b52d573073e298b7878558faff8e8d5a4a7444f4f2d2cca", + url = "https://ftp.mozilla.org/pub/firefox/releases/117.0/linux-x86_64/en-US/firefox-117.0.tar.bz2", + sha256 = "5acf61aed42bbf43dff8fee90c55fd3bcecb1c710b86cdd2c380b5e4db7f3998", build_file_content = """ filegroup( name = "files", @@ -27,8 +27,8 @@ exports_files( dmg_archive( name = "mac_firefox", - url = "https://ftp.mozilla.org/pub/firefox/releases/115.0.3/mac/en-US/Firefox%20115.0.3.dmg", - sha256 = "96b2616d0f95352caad756a200e0b13d20ee300be1d02fdfd3bab17ed6e73fa3", + url = "https://ftp.mozilla.org/pub/firefox/releases/117.0/mac/en-US/Firefox%20117.0.dmg", + sha256 = "eb9fcd6a7ea0feb56d64795367c32a1faea93db113d40b7a6b93e178af56e258", build_file_content = "exports_files([\"Firefox.app\"])", ) @@ -48,32 +48,32 @@ exports_files( pkg_archive( name = "mac_edge", - url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/1a586fcf-50fb-4714-9994-bef23c695628/MicrosoftEdge-115.0.1901.188.pkg", - sha256 = "c1bd8ab7e5d8972918ef089027515de14c892fb371a5b2c0322acadb46d29be8", + url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/a989b093-c982-4d31-95d1-2c439f49b7e7/MicrosoftEdge-116.0.1938.76.pkg", + sha256 = "d8676eb179b94be62e3a088367ae4525c96cd7bd79afdf3571b1e560a96c5643", move = { - "MicrosoftEdge-115.0.1901.188.pkg/Payload/Microsoft Edge.app": "Edge.app", + "MicrosoftEdge-116.0.1938.76.pkg/Payload/Microsoft Edge.app": "Edge.app", }, build_file_content = "exports_files([\"Edge.app\"])", ) http_archive( name = "linux_edgedriver", - url = "https://msedgedriver.azureedge.net/115.0.1901.188/edgedriver_linux64.zip", - sha256 = "8a5d10f0d6c43ecf1c6c503a301defcf648a46440c32437862add99839bc4446", + url = "https://msedgedriver.azureedge.net/116.0.1938.76/edgedriver_linux64.zip", + sha256 = "85b06da1719907402e4d78a1467e06539185c38b238019b6efb503000f3f04f8", build_file_content = "exports_files([\"msedgedriver\"])", ) http_archive( name = "mac_edgedriver", - url = "https://msedgedriver.azureedge.net/115.0.1901.188/edgedriver_mac64.zip", - sha256 = "934fdf4f620cba11ba039e8e7dc40a7e23d0a49b5896e5ba53f3be1fe7b4e6ef", + url = "https://msedgedriver.azureedge.net/116.0.1938.76/edgedriver_mac64.zip", + sha256 = "3b0b2ba7e7a7e99c78a00a3a830fe72d2c3825d66e592ce3664cff563ddc6828", build_file_content = "exports_files([\"msedgedriver\"])", ) http_archive( name = "linux_chrome", - url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5790.102/linux64/chrome-linux64.zip", - sha256 = "aebaecf70965f152a743935a95d0013de3e9d96e194106eb13dfc1b9b1c7892c", + url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/linux64/chrome-linux64.zip", + sha256 = "5d8ab1f999071b213d85e46ea4505d99df818b6fd0f8449e79710cb5403ba858", build_file_content = """ filegroup( name = "files", @@ -89,8 +89,8 @@ exports_files( http_archive( name = "mac_chrome", - url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5790.102/mac-x64/chrome-mac-x64.zip", - sha256 = "76e2fbb782e195259e7e7873ffca0e7270d52066af79a0d401c92d66382420ec", + url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/mac-x64/chrome-mac-x64.zip", + sha256 = "edc8e78f7a4b618037067593b2cb79ff571c16da0b955bc05a500af34b77d2fe", strip_prefix = "chrome-mac-x64", patch_cmds = [ "mv 'Google Chrome for Testing.app' Chrome.app", @@ -101,14 +101,16 @@ exports_files( http_archive( name = "linux_chromedriver", - url = "https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip", - sha256 = "a7787ef8b139170cab4abfca4a0284fd5d006bfd979624b4af25b64d583a6f44", + url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/linux64/chromedriver-linux64.zip", + sha256 = "17d225af124f9483a5d79a547f28f34253d7a1ef603ab7fb5ee185c0e4c71535", + strip_prefix = "chromedriver-linux64", build_file_content = "exports_files([\"chromedriver\"])", ) http_archive( name = "mac_chromedriver", - url = "https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_mac64.zip", - sha256 = "6abdc9d358c2bc4668bef7b23048de2a9dbd3ad82cfbc6dfe322e74d4cff1650", + url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/mac-x64/chromedriver-mac-x64.zip", + sha256 = "3ec691569dc8e98d803cf206c5fd4627e56836c81a5d1c9b7e5644a4e61ffd3f", + strip_prefix = "chromedriver-mac-x64", build_file_content = "exports_files([\"chromedriver\"])", ) diff --git a/java/test/org/openqa/selenium/bidi/BiDiTest.java b/java/test/org/openqa/selenium/bidi/BiDiTest.java index e1432e888b168..cb912fbf4a7ad 100644 --- a/java/test/org/openqa/selenium/bidi/BiDiTest.java +++ b/java/test/org/openqa/selenium/bidi/BiDiTest.java @@ -69,8 +69,9 @@ void canNavigateAndListenToErrors() page = server.whereIs("/bidi/logEntryAdded.html"); NavigationResult info = browsingContext.navigate(page, ReadinessState.COMPLETE); + // If navigation was successful, we expect both the url and navigation id to be set assertThat(browsingContext.getId()).isNotEmpty(); - assertThat(info.getNavigationId()).isNull(); + assertThat(info.getNavigationId()).isNotNull(); assertThat(info.getUrl()).contains("/bidi/logEntryAdded.html"); driver.findElement(By.id("jsException")).click(); diff --git a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverBiDiTest.java b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverBiDiTest.java index c16f4ca7d53c0..c0ca67728e32d 100644 --- a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverBiDiTest.java +++ b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverBiDiTest.java @@ -154,7 +154,7 @@ void canNavigateToUrl() { NavigationResult info = browsingContext.navigate(url); assertThat(browsingContext.getId()).isNotEmpty(); - assertThat(info.getNavigationId()).isNull(); + assertThat(info.getNavigationId()).isNotNull(); assertThat(info.getUrl()).contains("/bidi/logEntryAdded.html"); } diff --git a/scripts/pinned_browsers.py b/scripts/pinned_browsers.py index 912c618a2f218..0d5f2a3959cc0 100755 --- a/scripts/pinned_browsers.py +++ b/scripts/pinned_browsers.py @@ -19,51 +19,60 @@ def calculate_hash(url): h.update(b) return h.hexdigest() -def chromedriver(): - r = http.request('GET', 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE') - v = r.data.decode('utf-8') +def get_chrome_milestone(): + channel = "Stable" + r = http.request('GET', f'https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Mac,Linux') + all_versions = json.loads(r.data) + # use the same milestone for all chrome releases, so pick the lowest + milestone = min([version["milestone"] for version in all_versions if version["milestone"]]) + r = http.request('GET', 'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json') + versions = json.loads(r.data)["versions"] + return sorted( + filter(lambda v: v['version'].split('.')[0] == str(milestone), versions), + key=lambda v: LegacyVersion(v['version']) + )[-1] + +def chromedriver(): content = "" - linux = 'https://chromedriver.storage.googleapis.com/%s/chromedriver_linux64.zip' % v + selected_version = get_chrome_milestone() + + drivers = selected_version["downloads"]["chromedriver"] + + linux = [d["url"] for d in drivers if d["platform"] == "linux64"][0] sha = calculate_hash(linux) + content = content + """ http_archive( name = "linux_chromedriver", url = "%s", sha256 = "%s", + strip_prefix = "chromedriver-linux64", build_file_content = "exports_files([\\"chromedriver\\"])", ) """ % (linux, sha) - mac = 'https://chromedriver.storage.googleapis.com/%s/chromedriver_mac64.zip' % v + mac = [d["url"] for d in drivers if d["platform"] == "mac-x64"][0] sha = calculate_hash(mac) content = content + """ http_archive( name = "mac_chromedriver", url = "%s", sha256 = "%s", + strip_prefix = "chromedriver-mac-x64", build_file_content = "exports_files([\\"chromedriver\\"])", ) """ % (mac, sha) + return content def chrome(): - channel = "Stable" - r = http.request('GET', f'https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Win32,Windows,Mac,Linux') - milestone = json.loads(r.data)[0]["milestone"] - - r = http.request('GET', 'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json') - versions = json.loads(r.data)["versions"] - - selected_version = sorted( - filter(lambda v: v['version'].split('.')[0] == str(milestone), versions), - key=lambda v: LegacyVersion(v['version']) - )[-1] + selected_version = get_chrome_milestone() - downloads = selected_version["downloads"]["chrome"] + chrome_downloads = selected_version["downloads"]["chrome"] - linux = [d["url"] for d in downloads if d["platform"] == "linux64"][0] + linux = [d["url"] for d in chrome_downloads if d["platform"] == "linux64"][0] sha = calculate_hash(linux) content = """ @@ -86,7 +95,7 @@ def chrome(): """ % (linux, sha) - mac = [d["url"] for d in downloads if d["platform"] == "mac-x64"][0] + mac = [d["url"] for d in chrome_downloads if d["platform"] == "mac-x64"][0] sha = calculate_hash(mac) content += """ @@ -99,7 +108,7 @@ def chrome(): "mv 'Google Chrome for Testing.app' Chrome.app", "mv 'Chrome.app/Contents/MacOS/Google Chrome for Testing' Chrome.app/Contents/MacOS/Chrome", ], - build_file_content = "exports_files([\\"Google Chrome for Testing.app\\"])", + build_file_content = "exports_files([\\"Chrome.app\\"])", ) """ % (mac, sha) From b9e416460c90cd337fcc803d33b373964d270cf2 Mon Sep 17 00:00:00 2001 From: Simon Mavi Stewart Date: Tue, 12 Sep 2023 10:29:49 +0100 Subject: [PATCH 063/141] [ci] Might as well just run rustfmt, as that's what we want to happen --- scripts/format.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/format.sh b/scripts/format.sh index 1c62717c827f9..6800b0eb18279 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -17,5 +17,5 @@ echo " google-java-format" >&2 find "$PWD/java" -type f -name '*.java' | xargs "$GOOGLE_JAVA_FORMAT" --replace section "Rust" -echo " rustfmt (fix with: bazel run @rules_rust//:rustfmt)" >&2 -bazel test //rust/... --test_tag_filters="rust-rustfmt" --build_tests_only +echo " rustfmt" >&2 +bazel run @rules_rust//:rustfmt From 1e4a7bb11ea7b152706f33bf0b9b382e4d63f1e5 Mon Sep 17 00:00:00 2001 From: Sriharsha Date: Wed, 13 Sep 2023 11:50:44 +0530 Subject: [PATCH 064/141] Add FUNDING.yml with openCollective --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000000..2ddfd15779782 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +open_collective: selenium From 9d265b43b605d181892f31f43a21baa9a8414e3f Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Wed, 13 Sep 2023 12:15:02 +0200 Subject: [PATCH 065/141] Delete .github/FUNDING.yml --- .github/FUNDING.yml | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 2ddfd15779782..0000000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -open_collective: selenium From 4092a86b7d66bf45dd227f8a518cacddf57cea30 Mon Sep 17 00:00:00 2001 From: Manuel Blanco Date: Wed, 13 Sep 2023 10:23:10 -0300 Subject: [PATCH 066/141] Make variables final for improved code stability (#12733) --- java/src/org/openqa/selenium/lift/find/BaseFinder.java | 2 +- .../openqa/selenium/support/pagefactory/Annotations.java | 2 +- java/test/org/openqa/selenium/remote/AugmenterTest.java | 8 ++++---- .../support/pagefactory/AjaxElementLocatorTest.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/java/src/org/openqa/selenium/lift/find/BaseFinder.java b/java/src/org/openqa/selenium/lift/find/BaseFinder.java index 61bb0fbdec382..99fd2588302a6 100644 --- a/java/src/org/openqa/selenium/lift/find/BaseFinder.java +++ b/java/src/org/openqa/selenium/lift/find/BaseFinder.java @@ -31,7 +31,7 @@ @Deprecated public abstract class BaseFinder implements Finder { - protected List> matchers = new ArrayList<>(); + protected final List> matchers = new ArrayList<>(); @Override public Collection findFrom(T context) { diff --git a/java/src/org/openqa/selenium/support/pagefactory/Annotations.java b/java/src/org/openqa/selenium/support/pagefactory/Annotations.java index 17ba805774708..836b34332d838 100644 --- a/java/src/org/openqa/selenium/support/pagefactory/Annotations.java +++ b/java/src/org/openqa/selenium/support/pagefactory/Annotations.java @@ -29,7 +29,7 @@ import org.openqa.selenium.support.PageFactoryFinder; public class Annotations extends AbstractAnnotations { - private Field field; + private final Field field; /** * @param field expected to be an element in a Page Object diff --git a/java/test/org/openqa/selenium/remote/AugmenterTest.java b/java/test/org/openqa/selenium/remote/AugmenterTest.java index 82a191705cd47..9a17fbd2ece0d 100644 --- a/java/test/org/openqa/selenium/remote/AugmenterTest.java +++ b/java/test/org/openqa/selenium/remote/AugmenterTest.java @@ -330,9 +330,9 @@ public void expect(String commandName, Map args, Object returnValue) private static class Data { - public String commandName; - public Map args; - public Object returnValue; + public final String commandName; + public final Map args; + public final Object returnValue; public Data(String commandName, Map args, Object returnValue) { this.commandName = commandName; @@ -378,7 +378,7 @@ public interface HasNumbers { public static class ChildRemoteDriver extends RemoteWebDriver implements HasMagicNumbers { - private int magicNumber = 3; + private final int magicNumber = 3; @Override public Capabilities getCapabilities() { diff --git a/java/test/org/openqa/selenium/support/pagefactory/AjaxElementLocatorTest.java b/java/test/org/openqa/selenium/support/pagefactory/AjaxElementLocatorTest.java index ae238551fc698..6e018bc349e86 100644 --- a/java/test/org/openqa/selenium/support/pagefactory/AjaxElementLocatorTest.java +++ b/java/test/org/openqa/selenium/support/pagefactory/AjaxElementLocatorTest.java @@ -42,7 +42,7 @@ @Tag("UnitTests") class AjaxElementLocatorTest { - private TickingClock clock = new TickingClock(); + private final TickingClock clock = new TickingClock(); protected ElementLocator newLocator(WebDriver driver, Field field) { return new MonkeyedAjaxElementLocator(clock, driver, field, 10); From e5182732e95bddbaf91a042c6a70bacf20a5ac85 Mon Sep 17 00:00:00 2001 From: Oscar Devora <100381276+RevealOscar@users.noreply.github.com> Date: Wed, 13 Sep 2023 12:44:54 -0500 Subject: [PATCH 067/141] [rb] Add macos coverage to Ruby CI Github Action (#12556) * Add macos coverage to Ruby CI (#12397) * guard is not present in before all hook so do not set driver * after hook still executes even when guard disposition of the test is skip so explicitly skip it too --------- Co-authored-by: Titus Fortner Co-authored-by: titusfortner --- .github/workflows/bazel.yml | 3 +++ .github/workflows/ci-ruby.yml | 18 ++++++++++++++++ .../selenium/webdriver/action_builder_spec.rb | 20 +++++++++--------- .../selenium/webdriver/bidi_spec.rb | 8 ++++--- .../selenium/webdriver/chrome/driver_spec.rb | 6 ++---- .../selenium/webdriver/driver_spec.rb | 5 +++-- .../selenium/webdriver/firefox/driver_spec.rb | 4 +--- .../selenium/webdriver/manager_spec.rb | 4 ++-- .../selenium/webdriver/safari/driver_spec.rb | 4 ++-- .../selenium/webdriver/select_spec.rb | 21 ++++++++++++------- .../selenium/webdriver/shadow_root_spec.rb | 15 ++++++------- .../shared_examples/concurrent_driver.rb | 3 ++- .../webdriver/takes_screenshot_spec.rb | 4 +--- .../selenium/webdriver/window_spec.rb | 3 ++- 14 files changed, 73 insertions(+), 45 deletions(-) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 5b10b6e4a52a3..9999a6d905124 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -119,6 +119,9 @@ jobs: uses: browser-actions/setup-edge@latest with: edge-version: ${{ inputs.browser-version || 'stable' }} + - name: Setup Safari + if: inputs.browser == 'safari' + run: sudo safaridriver --enable - name: Run Bazel run: ${{ inputs.run }} - name: Start SSH session diff --git a/.github/workflows/ci-ruby.yml b/.github/workflows/ci-ruby.yml index 5a09e011e4631..80ced414f5fef 100644 --- a/.github/workflows/ci-ruby.yml +++ b/.github/workflows/ci-ruby.yml @@ -45,6 +45,8 @@ jobs: os: windows - ruby-version: 3.2.0 os: ubuntu + - ruby-version: 3.2.0 + os: macos - ruby-version: jruby-9.4.0.0 os: ubuntu - ruby-version: truffleruby-22.3.0 @@ -67,12 +69,20 @@ jobs: - chrome - edge - firefox + - safari os: - ubuntu - windows + - macos exclude: - browser: edge os: ubuntu + - browser: edge + os: macos + - browser: safari + os: ubuntu + - browser: safari + os: windows with: name: Local Tests (${{ matrix.browser }}, ${{ matrix.os }}) browser: ${{ matrix.browser }} @@ -96,12 +106,20 @@ jobs: - chrome - edge - firefox + - safari os: - ubuntu - windows + - macos exclude: - browser: edge os: ubuntu + - browser: edge + os: macos + - browser: safari + os: ubuntu + - browser: safari + os: windows with: name: Remote Tests (${{ matrix.browser }}, ${{ matrix.os }}) browser: ${{ matrix.browser }} diff --git a/rb/spec/integration/selenium/webdriver/action_builder_spec.rb b/rb/spec/integration/selenium/webdriver/action_builder_spec.rb index 457a89e1ea7ab..6dd6f198d8ba3 100644 --- a/rb/spec/integration/selenium/webdriver/action_builder_spec.rb +++ b/rb/spec/integration/selenium/webdriver/action_builder_spec.rb @@ -163,7 +163,7 @@ module WebDriver expect(element.attribute(:value)).to eq('DoubleClicked') end - it 'executes with equivalent pointer methods' do + it 'executes with equivalent pointer methods', except: {browser: %i[safari safari_preview]} do driver.navigate.to url_for('javascriptPage.html') element = driver.find_element(id: 'doubleClickField') @@ -203,8 +203,7 @@ module WebDriver end it 'moves to element with offset', except: {browser: :firefox, - ci: :github, - platform: :windows, + platform: %i[windows macosx], reason: 'Some issues with resolution?'} do driver.navigate.to url_for('javascriptPage.html') origin = driver.find_element(id: 'keyUpArea') @@ -263,7 +262,8 @@ module WebDriver end end - describe 'pen stylus', except: {browser: :firefox, reason: 'Unknown pointerType'} do + describe 'pen stylus', except: [{browser: :firefox, reason: 'Unknown pointerType'}, + {browser: :safari, reason: 'Some issues with resolution?'}] do it 'sets pointer event properties' do driver.navigate.to url_for('pointerActionsPage.html') pointer_area = driver.find_element(id: 'pointerArea') @@ -318,10 +318,9 @@ module WebDriver end end - describe '#scroll_by', only: {browser: %i[chrome edge firefox]} do + describe '#scroll_by' do it 'scrolls by given amount', except: {browser: :firefox, platform: :macosx, - headless: false, reason: 'scrolls insufficient number of pixels'} do driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html') footer = driver.find_element(tag_name: 'footer') @@ -334,9 +333,9 @@ module WebDriver end end - describe '#scroll_from', only: {browser: %i[chrome edge firefox]} do + describe '#scroll_from' do it 'scrolls from element by given amount', - except: {browser: :firefox, reason: 'incorrect MoveTargetOutOfBoundsError'} do + except: {browser: %i[firefox safari], reason: 'incorrect MoveTargetOutOfBoundsError'} do driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html') iframe = driver.find_element(tag_name: 'iframe') scroll_origin = WheelActions::ScrollOrigin.element(iframe) @@ -350,7 +349,7 @@ module WebDriver end it 'scrolls from element by given amount with offset', - except: {browser: :firefox, reason: 'incorrect MoveTargetOutOfBoundsError'} do + except: {browser: %i[firefox safari], reason: 'incorrect MoveTargetOutOfBoundsError'} do driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html') footer = driver.find_element(tag_name: 'footer') scroll_origin = WheelActions::ScrollOrigin.element(footer, 0, -50) @@ -387,7 +386,8 @@ module WebDriver expect(in_viewport?(checkbox)).to be true end - it 'raises MoveTargetOutOfBoundsError when origin offset is out of viewport' do + it 'raises MoveTargetOutOfBoundsError when origin offset is out of viewport', + only: {browser: %i[chrome edge firefox]} do driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame.html') scroll_origin = WheelActions::ScrollOrigin.viewport(-10, -10) diff --git a/rb/spec/integration/selenium/webdriver/bidi_spec.rb b/rb/spec/integration/selenium/webdriver/bidi_spec.rb index 497f066ad74df..7604bd1cfb504 100644 --- a/rb/spec/integration/selenium/webdriver/bidi_spec.rb +++ b/rb/spec/integration/selenium/webdriver/bidi_spec.rb @@ -36,7 +36,7 @@ module WebDriver expect(status.message).not_to be_empty end - it 'can navigate and listen to errors', except: {browser: %i[chrome edge], reason: 'not yet implemented'} do + it 'can navigate and listen to errors' do log_entry = nil log_inspector = BiDi::LogInspector.new(driver) log_inspector.on_javascript_exception { |log| log_entry = log } @@ -45,10 +45,12 @@ module WebDriver info = browsing_context.navigate(url: url_for('/bidi/logEntryAdded.html')) expect(browsing_context.id).not_to be_nil - expect(info.navigation_id).to be_nil + expect(info.navigation_id).not_to be_nil expect(info.url).to include('/bidi/logEntryAdded.html') - driver.find_element(id: 'jsException').click + js_exception = wait.until { driver.find_element(id: 'jsException') } + js_exception.click + wait.until { !log_entry.nil? } expect(log_entry).to have_attributes( diff --git a/rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb b/rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb index 737f5126c8747..a6fb7da579df3 100644 --- a/rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb +++ b/rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb @@ -52,10 +52,8 @@ module Chrome end describe 'PrintsPage' do - before(:all) do - @headless = ENV.delete('HEADLESS') - reset_driver!(args: ['--headless']) - end + before(:all) { @headless = ENV.delete('HEADLESS') } + before { reset_driver!(args: ['--headless']) } after(:all) do quit_driver diff --git a/rb/spec/integration/selenium/webdriver/driver_spec.rb b/rb/spec/integration/selenium/webdriver/driver_spec.rb index 2515ff727ca3a..5a5e748731c52 100644 --- a/rb/spec/integration/selenium/webdriver/driver_spec.rb +++ b/rb/spec/integration/selenium/webdriver/driver_spec.rb @@ -24,7 +24,7 @@ module WebDriver describe Driver do it_behaves_like 'driver that can be started concurrently', exclude: {browser: %i[safari safari_preview]} - it 'creates default capabilities' do + it 'creates default capabilities', exclude: {browser: %i[safari safari_preview]} do reset_driver! do |driver| caps = driver.capabilities expect(caps.proxy).to be_nil @@ -147,7 +147,8 @@ module WebDriver }.to raise_error(Error::NoSuchElementError, /errors#no-such-element-exception/) end - it 'raises if invalid locator' do + it 'raises if invalid locator', + exclude: {browser: %i[safari safari_preview], reason: 'Safari raises TimeoutError'} do driver.navigate.to url_for('xhtmlTest.html') expect { driver.find_element(xpath: '*?//-') diff --git a/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb index b0ce3807a108e..9ec85e2479ed8 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb @@ -44,11 +44,9 @@ module Firefox page: {width: 30})).to include(magic_number) end - it 'prints full page', except: [{ci: :github, - platform: :windows, + it 'prints full page', except: [{platform: :windows, reason: 'Some issues with resolution?'}, {platform: :macosx, - headless: true, reason: 'showing half resolution of what expected'}] do viewport_width = driver.execute_script('return window.innerWidth;') viewport_height = driver.execute_script('return window.innerHeight;') diff --git a/rb/spec/integration/selenium/webdriver/manager_spec.rb b/rb/spec/integration/selenium/webdriver/manager_spec.rb index cf1708a5f00cf..600ebc68261c3 100644 --- a/rb/spec/integration/selenium/webdriver/manager_spec.rb +++ b/rb/spec/integration/selenium/webdriver/manager_spec.rb @@ -134,7 +134,7 @@ module WebDriver end describe 'sameSite' do - it 'allows adding with value Strict', only: {browser: %i[chrome edge firefox]} do + it 'allows adding with value Strict' do driver.manage.add_cookie name: 'samesite', value: 'strict', same_site: 'Strict' @@ -142,7 +142,7 @@ module WebDriver expect(driver.manage.cookie_named('samesite')[:same_site]).to eq('Strict') end - it 'allows adding with value Lax', only: {browser: %i[chrome edge firefox]} do + it 'allows adding with value Lax' do driver.manage.add_cookie name: 'samesite', value: 'lax', same_site: 'Lax' diff --git a/rb/spec/integration/selenium/webdriver/safari/driver_spec.rb b/rb/spec/integration/selenium/webdriver/safari/driver_spec.rb index c936217809e6a..541e35ef4fdb9 100644 --- a/rb/spec/integration/selenium/webdriver/safari/driver_spec.rb +++ b/rb/spec/integration/selenium/webdriver/safari/driver_spec.rb @@ -36,13 +36,13 @@ module Safari Safari.use_technology_preview = nil end - it 'sets before options', exclusive: {browser: :safari} do + it 'sets before options', exclusive: {browser: :safari_preview} do Safari.technology_preview! local_driver = WebDriver.for :safari expect(local_driver.capabilities.browser_name).to eq 'Safari Technology Preview' end - it 'sets after options' do + it 'sets after options', exclusive: {browser: :safari_preview} do options = Options.safari Safari.technology_preview! local_driver = WebDriver.for :safari, options: options diff --git a/rb/spec/integration/selenium/webdriver/select_spec.rb b/rb/spec/integration/selenium/webdriver/select_spec.rb index ca689a944a47c..715dbe5e7ba89 100644 --- a/rb/spec/integration/selenium/webdriver/select_spec.rb +++ b/rb/spec/integration/selenium/webdriver/select_spec.rb @@ -109,7 +109,8 @@ module Support expect(selected_options).to include(driver.find_element(css: 'option[value="onion gravy"]')) end - it 'errors when option disabled' do + it 'errors when option disabled', + exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do expect { multi_disabled.select_by(:text, 'Disabled') }.to raise_exception(Error::UnsupportedOperationError) @@ -137,7 +138,8 @@ module Support expect(selected_options).to include(driver.find_element(css: 'option[value=ham]')) end - it 'errors when option disabled' do + it 'errors when option disabled', + exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do expect { multi_disabled.select_by(:index, 1) }.to raise_exception(Error::UnsupportedOperationError) end @@ -163,7 +165,8 @@ module Support expect(selected_options).to include(driver.find_element(css: 'option[value=ham]')) end - it 'errors when option disabled' do + it 'errors when option disabled', + exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do expect { multi_disabled.select_by(:value, 'disabled') }.to raise_exception(Error::UnsupportedOperationError) @@ -197,7 +200,8 @@ module Support expect(select.selected_options).to eq([expected_option]) end - it 'errors when option disabled' do + it 'errors when option disabled', + exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do expect { single_disabled.select_by(:text, 'Disabled') }.to raise_exception(Error::UnsupportedOperationError) @@ -223,7 +227,8 @@ module Support expect(selected_options).to eq([driver.find_element(css: 'option[value="two"]')]) end - it 'errors when option disabled' do + it 'errors when option disabled', + exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do expect { single_disabled.select_by(:index, 1) }.to raise_exception(Error::UnsupportedOperationError) end @@ -247,7 +252,8 @@ module Support expect(selected_options).to eq([driver.find_element(css: 'option[value="two"]')]) end - it 'errors when option disabled' do + it 'errors when option disabled', + exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do expect { single_disabled.select_by(:value, 'disabled') }.to raise_exception(Error::UnsupportedOperationError) @@ -345,7 +351,8 @@ module Support expect { select.select_all }.to raise_exception(Error::UnsupportedOperationError) end - it 'raises exception if select contains disabled options' do + it 'raises exception if select contains disabled options', + exclude: {browser: :safari, reason: 'Safari raises no exception with disabled'} do select = described_class.new(driver.find_element(name: 'multi_disabled')) expect { select.select_all }.to raise_exception(Error::UnsupportedOperationError) diff --git a/rb/spec/integration/selenium/webdriver/shadow_root_spec.rb b/rb/spec/integration/selenium/webdriver/shadow_root_spec.rb index 912c91b1c34af..91b9f889dccbc 100644 --- a/rb/spec/integration/selenium/webdriver/shadow_root_spec.rb +++ b/rb/spec/integration/selenium/webdriver/shadow_root_spec.rb @@ -21,7 +21,7 @@ module Selenium module WebDriver - describe ShadowRoot, only: {browser: %i[chrome firefox edge]} do + describe ShadowRoot, only: {browser: %i[chrome firefox edge safari]} do before { driver.navigate.to url_for('webComponents.html') } let(:custom_element) { driver.find_element(css: 'custom-checkbox-element') } @@ -31,13 +31,14 @@ module WebDriver expect(shadow_root).to be_a described_class end - it 'raises error if no shadow root' do + it 'raises error if no shadow root', exclude: {browser: :safari, reason: 'NoMethodError'} do driver.navigate.to url_for('simpleTest.html') div = driver.find_element(css: 'div') expect { div.shadow_root }.to raise_error(Error::NoSuchShadowRootError) end - it 'gets shadow root from script' do + it 'gets shadow root from script', + exclude: {browser: :safari, reason: 'returns correct node, but references shadow root as a element'} do shadow_root = custom_element.shadow_root execute_shadow_root = driver.execute_script('return arguments[0].shadowRoot;', custom_element) expect(execute_shadow_root).to eq shadow_root @@ -51,7 +52,7 @@ module WebDriver expect(element).to be_a Element end - it 'by xpath', except: {browser: %i[chrome edge firefox], + it 'by xpath', except: {browser: %i[chrome edge firefox safari], reason: 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=4097'} do shadow_root = custom_element.shadow_root element = shadow_root.find_element(xpath: "//input[type='checkbox']") @@ -73,7 +74,7 @@ module WebDriver expect(element).to be_a Element end - it 'by tag name', except: {browser: %i[chrome edge firefox], + it 'by tag name', except: {browser: %i[chrome edge firefox safari], reason: 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=4097'} do shadow_root = custom_element.shadow_root element = shadow_root.find_element(tag_name: 'input') @@ -97,7 +98,7 @@ module WebDriver expect(elements.first).to be_a Element end - it 'by xpath', except: {browser: %i[chrome edge firefox], + it 'by xpath', except: {browser: %i[chrome edge firefox safari], reason: 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=4097'} do shadow_root = custom_element.shadow_root elements = shadow_root.find_elements(xpath: "//input[type='checkbox']") @@ -122,7 +123,7 @@ module WebDriver expect(elements.first).to be_a Element end - it 'by tag name', except: {browser: %i[chrome edge firefox], + it 'by tag name', except: {browser: %i[chrome edge firefox safari], reason: 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=4097'} do shadow_root = custom_element.shadow_root elements = shadow_root.find_elements(tag_name: 'input') diff --git a/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb b/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb index cf9ce8d7e1545..e3728572e5efd 100644 --- a/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb +++ b/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb @@ -23,7 +23,8 @@ before { quit_driver } - after do + after do |example| + skip if example.metadata[:skip] drivers.each(&:quit) threads.select(&:alive?).each(&:kill) create_driver! diff --git a/rb/spec/integration/selenium/webdriver/takes_screenshot_spec.rb b/rb/spec/integration/selenium/webdriver/takes_screenshot_spec.rb index c9843279ac200..884cde1440b91 100644 --- a/rb/spec/integration/selenium/webdriver/takes_screenshot_spec.rb +++ b/rb/spec/integration/selenium/webdriver/takes_screenshot_spec.rb @@ -95,11 +95,9 @@ def save_screenshot_and_assert(source, path) expect(height).to be <= viewport_height end - it 'takes full page screenshot', except: [{ci: :github, - platform: :windows, + it 'takes full page screenshot', except: [{platform: :windows, reason: 'Some issues with resolution?'}, {platform: :macosx, - headless: true, reason: 'showing half resolution of what expected'}], exclusive: {browser: :firefox} do viewport_width = driver.execute_script('return window.innerWidth;') diff --git a/rb/spec/integration/selenium/webdriver/window_spec.rb b/rb/spec/integration/selenium/webdriver/window_spec.rb index 7cc1ac56db899..e8a912abfda57 100644 --- a/rb/spec/integration/selenium/webdriver/window_spec.rb +++ b/rb/spec/integration/selenium/webdriver/window_spec.rb @@ -124,7 +124,8 @@ module WebDriver expect(new_size.height).to be > old_size.height end - it 'can minimize the window', except: {browser: %i[chrome edge], headless: true} do + it 'can minimize the window', except: [{browser: %i[chrome edge], headless: true}, + {browser: :safari, ci: :github}] do window.minimize expect { wait.until { driver.execute_script('return document.hidden;') } From b687c7b8a1d2929426991329ae38b00a80960323 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Thu, 14 Sep 2023 09:53:44 -0400 Subject: [PATCH 068/141] [atoms] Update fragment.bzl to fix a bug where "_" was overwritten (#12704) * Update fragment.bzl to fix bug where "_" was overwritten Update fragment.bzl to fix bug where "_" was overwritten * Update fragment.bzl (full revert) Update fragment.bzl (full revert) --- javascript/private/fragment.bzl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/javascript/private/fragment.bzl b/javascript/private/fragment.bzl index 05cc0f24dc1f2..d5d6ed1b1d7cb 100644 --- a/javascript/private/fragment.bzl +++ b/javascript/private/fragment.bzl @@ -51,11 +51,18 @@ def closure_fragment( # Wrap the output in two functions. The outer function ensures the # compiled fragment never pollutes the global scope by using its - # own scope on each invocation. + # own scope on each invocation. We must import window.navigator into + # this unique scope since Closure's goog.userAgent package assumes + # navigator and document are defined on goog.global. Normally, this + # would be window, but we are explicitly defining the fragment so that + # goog.global is _not_ window. + # See http://code.google.com/p/selenium/issues/detail?id=1333 wrapper = ( "function(){" + - "return (function(){%output%; return this._.apply(null,arguments);}).apply(" + - "window, arguments);}" + "return (function(){%output%; return this._.apply(null,arguments);}).apply({" + + "navigator:typeof window!='undefined'?window.navigator:null," + + "document:typeof window!='undefined'?window.document:null" + + "}, arguments);}" ) browser_defs = { From 9bffabd4df520885275a40587c9ccebe0c1bb78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boni=20Garc=C3=ADa?= Date: Fri, 15 Sep 2023 17:29:38 +0200 Subject: [PATCH 069/141] [rust] Avoid using robocopy to move extracted files from sfx in windows (#12690) --- rust/src/files.rs | 27 +++++++++++++++------------ rust/src/lib.rs | 1 - 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/rust/src/files.rs b/rust/src/files.rs index 1c9c4cf74129c..b71240647a617 100644 --- a/rust/src/files.rs +++ b/rust/src/files.rs @@ -36,7 +36,7 @@ use crate::config::OS::WINDOWS; use crate::{ format_one_arg, format_three_args, format_two_args, run_shell_command_by_os, Command, Logger, CP_VOLUME_COMMAND, HDIUTIL_ATTACH_COMMAND, HDIUTIL_DETACH_COMMAND, MACOS, MV_PAYLOAD_COMMAND, - MV_PAYLOAD_OLD_VERSIONS_COMMAND, MV_SFX_COMMAND, PKGUTIL_COMMAND, + MV_PAYLOAD_OLD_VERSIONS_COMMAND, PKGUTIL_COMMAND, }; pub const PARSE_ERROR: &str = "Wrong browser/driver version"; @@ -135,7 +135,7 @@ pub fn uncompress( } else if extension.eq_ignore_ascii_case(DMG) { uncompress_dmg(compressed_file, target, log, os, volume.unwrap_or_default())? } else if extension.eq_ignore_ascii_case(EXE) { - uncompress_sfx(compressed_file, target, log, os)? + uncompress_sfx(compressed_file, target, log)? } else if extension.eq_ignore_ascii_case(XML) || extension.eq_ignore_ascii_case(HTML) { log.debug(format!( "Wrong downloaded driver: {}", @@ -156,26 +156,29 @@ pub fn uncompress_sfx( compressed_file: &str, target: &Path, log: &Logger, - os: &str, ) -> Result<(), Box> { + let zip_parent = Path::new(compressed_file).parent().unwrap(); log.trace(format!( - "Uncompress {} to {}", + "Decompressing {} to {}", compressed_file, - target.display() + zip_parent.display() )); + let file_bytes = read_bytes_from_file(compressed_file)?; let header = find_bytes(&file_bytes, SEVEN_ZIP_HEADER); let index_7z = header.ok_or("Incorrect SFX (self extracting exe) file")?; let file_reader = Cursor::new(&file_bytes[index_7z..]); - sevenz_rust::decompress(file_reader, target).unwrap(); + sevenz_rust::decompress(file_reader, zip_parent).unwrap(); + let zip_parent_str = path_buf_to_string(zip_parent.to_path_buf()); let target_str = path_buf_to_string(target.to_path_buf()); - let command = Command::new_single(format_two_args(MV_SFX_COMMAND, &target_str, &target_str)); - log.trace(format!("Running command: {}", command.display())); - run_shell_command_by_os(os, command)?; - - let setup_file = target.join("setup.exe"); - fs::remove_file(setup_file.as_path())?; + let core_str = format!(r#"{}\core"#, zip_parent_str); + log.trace(format!( + "Moving extracted files and folders from {} to {}", + core_str, target_str + )); + create_parent_path_if_not_exists(target)?; + fs::rename(&core_str, &target_str)?; Ok(()) } diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 432c0d0ec8582..16da9ac056597 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -80,7 +80,6 @@ pub const HDIUTIL_DETACH_COMMAND: &str = "hdiutil detach /Volumes/{}"; pub const CP_VOLUME_COMMAND: &str = "cp -R /Volumes/{}/{}.app {}"; pub const MV_PAYLOAD_COMMAND: &str = "mv {}/*{}/Payload/*.app {}"; pub const MV_PAYLOAD_OLD_VERSIONS_COMMAND: &str = "mv {}/Payload/*.app {}"; -pub const MV_SFX_COMMAND: &str = r#"robocopy {}\core {} /e /move"#; pub const DASH_VERSION: &str = "{}{}{} -v"; pub const DASH_DASH_VERSION: &str = "{}{}{} --version"; pub const DOUBLE_QUOTE: &str = "\""; From d1a1c028e808e19b198ec9d2422e8a4ba80c4ac2 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 15 Sep 2023 21:54:57 +0300 Subject: [PATCH 070/141] [dotnet] Indicate end of output taken from selenium manager (#12744) Indicate end of output taken from selenium manager --- dotnet/src/webdriver/SeleniumManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dotnet/src/webdriver/SeleniumManager.cs b/dotnet/src/webdriver/SeleniumManager.cs index 070f0b1e71d71..e051ef025ba5b 100644 --- a/dotnet/src/webdriver/SeleniumManager.cs +++ b/dotnet/src/webdriver/SeleniumManager.cs @@ -163,20 +163,20 @@ private static Dictionary RunCommand(string fileName, string arg var exceptionMessageBuilder = new StringBuilder($"Selenium Manager process exited abnormally with {process.ExitCode} code: {fileName} {arguments}"); - if (!string.IsNullOrEmpty(errorOutputBuilder.ToString())) + if (!string.IsNullOrWhiteSpace(errorOutputBuilder.ToString())) { exceptionMessageBuilder.AppendLine(); - exceptionMessageBuilder.Append("Error Output >>"); - exceptionMessageBuilder.AppendLine(); + exceptionMessageBuilder.AppendLine("Error Output >>"); exceptionMessageBuilder.Append(errorOutputBuilder); + exceptionMessageBuilder.AppendLine("<<"); } - if (!string.IsNullOrEmpty(outputBuilder.ToString())) + if (!string.IsNullOrWhiteSpace(outputBuilder.ToString())) { exceptionMessageBuilder.AppendLine(); - exceptionMessageBuilder.Append("Standard Output >>"); - exceptionMessageBuilder.AppendLine(); + exceptionMessageBuilder.AppendLine("Standard Output >>"); exceptionMessageBuilder.Append(outputBuilder); + exceptionMessageBuilder.AppendLine("<<"); } throw new WebDriverException(exceptionMessageBuilder.ToString()); From 61fe50b81905430b1dfbff38b0bdce82aeb2725b Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 15 Sep 2023 21:56:31 +0300 Subject: [PATCH 071/141] [dotnet] Declare selenium manager binaries as content (#12711) Declare selenium manager binaries as content --- .../src/webdriver/build/Selenium.WebDriver.targets | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dotnet/src/webdriver/build/Selenium.WebDriver.targets b/dotnet/src/webdriver/build/Selenium.WebDriver.targets index fab907a12fb1e..88abbf0f50a11 100644 --- a/dotnet/src/webdriver/build/Selenium.WebDriver.targets +++ b/dotnet/src/webdriver/build/Selenium.WebDriver.targets @@ -6,23 +6,23 @@ - + selenium-manager\linux\%(Filename)%(Extension) PreserveNewest False - + - + selenium-manager\macos\%(Filename)%(Extension) PreserveNewest False - + - + selenium-manager\windows\%(Filename)%(Extension) PreserveNewest False - + From 810123657d82a335a88acc5098a49a9052c668d1 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Fri, 15 Sep 2023 20:56:21 -0500 Subject: [PATCH 072/141] [rust] do not log warning for default value --- rust/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index feb6961ac5715..507be9ff9fe0d 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -163,7 +163,7 @@ fn main() { } cli.force_browser_download = false; if !cli.avoid_browser_download { - log.warn("Offline flag set, but also asked not to avoid browser downloads. Honouring offline flag"); + log.debug("Offline flag set, but also asked not to avoid browser downloads. Honouring offline flag"); } cli.avoid_browser_download = true; } From eafd7cfff0e4fb34882f9a7a3d86138d6fadefc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boni=20Garc=C3=ADa?= Date: Sat, 16 Sep 2023 03:57:22 +0200 Subject: [PATCH 073/141] [rust] Search better driver possible in the cache (#12753) * [rust] Search better driver possible in the cache * [rust] Update Cargo.Bazel.lock --- rust/Cargo.Bazel.lock | 93 ++++++++++++++++++++++++++++++++++++- rust/Cargo.lock | 20 ++++++++ rust/Cargo.toml | 1 + rust/src/lib.rs | 69 +++++++++++++++++++++++++++ rust/src/main.rs | 40 +++++++++++----- rust/tests/browser_tests.rs | 18 +++---- rust/tests/common.rs | 21 +++++++++ rust/tests/grid_tests.rs | 10 ++-- rust/tests/proxy_tests.rs | 48 +++++++++---------- 9 files changed, 266 insertions(+), 54 deletions(-) diff --git a/rust/Cargo.Bazel.lock b/rust/Cargo.Bazel.lock index 198a870979394..6e4b08cf9ae1c 100644 --- a/rust/Cargo.Bazel.lock +++ b/rust/Cargo.Bazel.lock @@ -1,5 +1,5 @@ { - "checksum": "0c722a74f5cadc8bb75a62763e298e0698afcb48a51d9f7bf6754e285caa644b", + "checksum": "1f16f4cfa433faeb0bd8242b382da4d71e41405dc8a07363d8c1f410ee0d651e", "crates": { "addr2line 0.19.0": { "name": "addr2line", @@ -7636,6 +7636,47 @@ }, "license": "Apache-2.0 OR BSL-1.0" }, + "same-file 1.0.6": { + "name": "same-file", + "version": "1.0.6", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/same-file/1.0.6/download", + "sha256": "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" + } + }, + "targets": [ + { + "Library": { + "crate_name": "same_file", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "same_file", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [], + "selects": { + "cfg(windows)": [ + { + "id": "winapi-util 0.1.5", + "target": "winapi_util" + } + ] + } + }, + "edition": "2018", + "version": "1.0.6" + }, + "license": "Unlicense/MIT" + }, "sct 0.7.0": { "name": "sct", "version": "0.7.0", @@ -7773,6 +7814,10 @@ "id": "toml 0.7.6", "target": "toml" }, + { + "id": "walkdir 2.4.0", + "target": "walkdir" + }, { "id": "zip 0.6.6", "target": "zip" @@ -10300,6 +10345,52 @@ }, "license": "MIT/Apache-2.0" }, + "walkdir 2.4.0": { + "name": "walkdir", + "version": "2.4.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/walkdir/2.4.0/download", + "sha256": "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" + } + }, + "targets": [ + { + "Library": { + "crate_name": "walkdir", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "walkdir", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "same-file 1.0.6", + "target": "same_file" + } + ], + "selects": { + "cfg(windows)": [ + { + "id": "winapi-util 0.1.5", + "target": "winapi_util" + } + ] + } + }, + "edition": "2018", + "version": "2.4.0" + }, + "license": "Unlicense/MIT" + }, "want 0.3.0": { "name": "want", "version": "0.3.0", diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 8c184bca0f424..d47875b011c9a 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1419,6 +1419,15 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "sct" version = "0.7.0" @@ -1453,6 +1462,7 @@ dependencies = [ "tempfile", "tokio", "toml", + "walkdir", "zip", ] @@ -1924,6 +1934,16 @@ dependencies = [ "libc", ] +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.0" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index da249cb86e32e..771e33faca147 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -31,6 +31,7 @@ is_executable = "1.0.1" toml = "0.7.6" bzip2 = "0.4.4" sevenz-rust = "0.5.2" +walkdir = "2.4.0" [dev-dependencies] assert_cmd = "2.0.12" diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 16da9ac056597..20c2bea78e505 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -34,6 +34,7 @@ use std::collections::HashMap; use std::error::Error; use std::path::{Path, PathBuf}; use std::time::Duration; +use walkdir::{DirEntry, WalkDir}; use crate::downloads::download_to_tmp_folder; use crate::files::{parse_version, uncompress, BrowserPath}; @@ -593,6 +594,74 @@ pub trait SeleniumManager { Ok(driver_path) } + fn is_driver(&self, entry: &DirEntry) -> bool { + let is_file = entry.path().is_file(); + + let is_driver = entry + .file_name() + .to_str() + .map(|s| s.contains(&self.get_driver_name_with_extension())) + .unwrap_or(false); + + let match_os = entry + .path() + .to_str() + .map(|s| s.contains(self.get_platform_label())) + .unwrap_or(false); + + is_file && is_driver && match_os + } + + fn is_driver_and_matches_browser_version(&self, entry: &DirEntry) -> bool { + let match_driver_version = entry + .path() + .parent() + .unwrap_or(entry.path()) + .file_name() + .map(|s| { + s.to_str() + .unwrap_or_default() + .starts_with(&self.get_major_browser_version()) + }) + .unwrap_or(false); + + self.is_driver(entry) && match_driver_version + } + + fn find_best_driver_from_cache(&self) -> Result, Box> { + let cache_path = self.get_cache_path()?; + let drivers_in_cache_matching_version: Vec = WalkDir::new(&cache_path) + .into_iter() + .filter_map(|entry| entry.ok()) + .filter(|entry| self.is_driver_and_matches_browser_version(entry)) + .map(|entry| entry.path().to_owned()) + .collect(); + + // First we look for drivers in cache that matches browser version (should work for Chrome and Edge) + if !drivers_in_cache_matching_version.is_empty() { + Ok(Some( + drivers_in_cache_matching_version + .iter() + .last() + .unwrap() + .to_owned(), + )) + } else { + // If not available, we look for the latest available driver in the cache + let drivers_in_cache: Vec = WalkDir::new(&cache_path) + .into_iter() + .filter_map(|entry| entry.ok()) + .filter(|entry| self.is_driver(entry)) + .map(|entry| entry.path().to_owned()) + .collect(); + if !drivers_in_cache.is_empty() { + Ok(Some(drivers_in_cache.iter().last().unwrap().to_owned())) + } else { + Ok(None) + } + } + } + fn get_major_version(&self, full_version: &str) -> Result> { get_index_version(full_version, 0) } diff --git a/rust/src/main.rs b/rust/src/main.rs index 507be9ff9fe0d..e4fbab3a7fc1a 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +use std::path::PathBuf; use std::process::exit; use clap::Parser; @@ -194,21 +195,26 @@ fn main() { .and_then(|_| selenium_manager.setup()) .map(|driver_path| { let log = selenium_manager.get_logger(); - if driver_path.exists() { - log.info(format!("{}{}", DRIVER_PATH, driver_path.display())); - } else { - log.error(format!("Driver unavailable: {}", DRIVER_PATH)); - flush_and_exit(UNAVAILABLE, log); - } - let browser_path = selenium_manager.get_browser_path(); - if !browser_path.is_empty() { - log.info(format!("{}{}", BROWSER_PATH, browser_path)); - } + log_driver_and_browser_path(log, &driver_path, selenium_manager.get_browser_path()); flush_and_exit(OK, log); }) .unwrap_or_else(|err| { let log = selenium_manager.get_logger(); - if selenium_manager.is_offline() { + if let Some(best_driver_from_cache) = + selenium_manager.find_best_driver_from_cache().unwrap() + { + log.warn(format!( + "There was an error managing {} ({}); using driver found in the cache", + selenium_manager.get_browser_name(), + err + )); + log_driver_and_browser_path( + log, + &best_driver_from_cache, + selenium_manager.get_browser_path(), + ); + flush_and_exit(OK, log); + } else if selenium_manager.is_offline() { log.warn(err.to_string()); flush_and_exit(OK, log); } else { @@ -218,6 +224,18 @@ fn main() { }); } +fn log_driver_and_browser_path(log: &Logger, driver_path: &PathBuf, browser_path: &str) { + if driver_path.exists() { + log.info(format!("{}{}", DRIVER_PATH, driver_path.display())); + } else { + log.error(format!("Driver unavailable: {}", DRIVER_PATH)); + flush_and_exit(UNAVAILABLE, log); + } + if !browser_path.is_empty() { + log.info(format!("{}{}", BROWSER_PATH, browser_path)); + } +} + fn flush_and_exit(code: i32, log: &Logger) -> ! { log.set_code(code); log.flush(); diff --git a/rust/tests/browser_tests.rs b/rust/tests/browser_tests.rs index 69baa8b59fa9d..14818e892c519 100644 --- a/rust/tests/browser_tests.rs +++ b/rust/tests/browser_tests.rs @@ -19,6 +19,10 @@ use assert_cmd::Command; use rstest::rstest; use std::env::consts::OS; +use crate::common::assert_output; + +mod common; + #[rstest] #[case("chrome", "chromedriver", "114", "114.0.5735.90")] #[case("chrome", "chromedriver", "115", "115.0.5790")] @@ -68,7 +72,7 @@ fn wrong_parameters_test( #[case] error_code: i32, ) { let mut cmd = Command::new(env!("CARGO_BIN_EXE_selenium-manager")); - let assert_result = cmd + let result = cmd .args([ "--debug", "--browser", @@ -81,17 +85,7 @@ fn wrong_parameters_test( .assert() .try_success(); - if assert_result.is_ok() { - let stdout = &cmd.unwrap().stdout; - let output = std::str::from_utf8(stdout).unwrap(); - assert!(output.contains("in PATH")); - } else { - assert!(assert_result - .err() - .unwrap() - .to_string() - .contains(&error_code.to_string())); - } + assert_output(&mut cmd, result, "in PATH", error_code); } #[rstest] diff --git a/rust/tests/common.rs b/rust/tests/common.rs index 81dd923ebba89..4e53f72d0d581 100644 --- a/rust/tests/common.rs +++ b/rust/tests/common.rs @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +use assert_cmd::assert::AssertResult; use assert_cmd::Command; use std::borrow::BorrowMut; use std::env::consts::OS; @@ -72,3 +73,23 @@ pub fn display_output(cmd: &mut Command) { let output = std::str::from_utf8(stdout).unwrap(); println!("{}", output); } + +#[allow(dead_code)] +pub fn assert_output( + cmd: &mut Command, + assert_result: AssertResult, + expected_output: &str, + error_code: i32, +) { + if assert_result.is_ok() { + let stdout = &cmd.unwrap().stdout; + let output = std::str::from_utf8(stdout).unwrap(); + assert!(output.contains(expected_output)); + } else { + assert!(assert_result + .err() + .unwrap() + .to_string() + .contains(&error_code.to_string())); + } +} diff --git a/rust/tests/grid_tests.rs b/rust/tests/grid_tests.rs index 7d2385b3a6ad5..3f5f4958f7ea8 100644 --- a/rust/tests/grid_tests.rs +++ b/rust/tests/grid_tests.rs @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +use crate::common::assert_output; use assert_cmd::Command; use exitcode::DATAERR; use rstest::rstest; @@ -22,6 +23,8 @@ use selenium_manager::logger::JsonOutput; use std::path::Path; use std::str; +mod common; + #[test] fn grid_latest_test() { let mut cmd = Command::new(env!("CARGO_BIN_EXE_selenium-manager")); @@ -73,8 +76,7 @@ fn grid_version_test(#[case] grid_version: &str) { #[case("99.99.99")] fn grid_error_test(#[case] grid_version: &str) { let mut cmd = Command::new(env!("CARGO_BIN_EXE_selenium-manager")); - cmd.args(["--grid", grid_version]) - .assert() - .failure() - .code(DATAERR); + let result = cmd.args(["--grid", grid_version]).assert().try_success(); + + assert_output(&mut cmd, result, "There was an error", DATAERR); } diff --git a/rust/tests/proxy_tests.rs b/rust/tests/proxy_tests.rs index 8b62ec56a1834..51d4b08fe0220 100644 --- a/rust/tests/proxy_tests.rs +++ b/rust/tests/proxy_tests.rs @@ -15,14 +15,16 @@ // specific language governing permissions and limitations // under the License. +use crate::common::assert_output; use assert_cmd::Command; use exitcode::DATAERR; -use std::str; + +mod common; #[tokio::test] async fn wrong_proxy_test() { let mut cmd = Command::new(env!("CARGO_BIN_EXE_selenium-manager")); - let assert_result = cmd + let result = cmd .args([ "--debug", "--browser", @@ -32,38 +34,32 @@ async fn wrong_proxy_test() { ]) .assert() .try_success(); - if assert_result.is_ok() { - let stdout = &cmd.unwrap().stdout; - let output = str::from_utf8(stdout).unwrap(); - assert!(output.contains("in PATH")); - } else { - assert!(assert_result - .err() - .unwrap() - .to_string() - .contains(&DATAERR.to_string())); - } -} + assert_output(&mut cmd, result, "in PATH", DATAERR); +} #[test] fn wrong_protocol_proxy_test() { let mut cmd = Command::new(env!("CARGO_BIN_EXE_selenium-manager")); - cmd.args(["--browser", "chrome", "--proxy", "wrong:://proxy"]) + let result = cmd + .args(["--browser", "chrome", "--proxy", "wrong:://proxy"]) .assert() - .failure() - .code(DATAERR); + .try_success(); + + assert_output(&mut cmd, result, "There was an error", DATAERR); } #[test] fn wrong_port_proxy_test() { let mut cmd = Command::new(env!("CARGO_BIN_EXE_selenium-manager")); - cmd.args([ - "--browser", - "chrome", - "--proxy", - "https:://localhost:1234567", - ]) - .assert() - .failure() - .code(DATAERR); + let result = cmd + .args([ + "--browser", + "chrome", + "--proxy", + "https:://localhost:1234567", + ]) + .assert() + .try_success(); + + assert_output(&mut cmd, result, "There was an error", DATAERR); } From 6c846218f861375464fb8d311eed1bd8029bbecc Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 16 Sep 2023 04:59:51 +0300 Subject: [PATCH 074/141] [dotnet] Return back AlertsTest on .net 4.8 (#12702) Return back AlertsTest on .net 4.8 --- dotnet/test/common/AlertsTest.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/dotnet/test/common/AlertsTest.cs b/dotnet/test/common/AlertsTest.cs index 1e37a3b9baafc..348c5ee3035cf 100644 --- a/dotnet/test/common/AlertsTest.cs +++ b/dotnet/test/common/AlertsTest.cs @@ -6,7 +6,6 @@ namespace OpenQA.Selenium { [TestFixture] - [IgnoreTarget("net48", "Cannot create inline page with UrlBuilder")] public class AlertsTest : DriverTestFixture { [Test] From b56c0b609cef759229d270b779aec38a8f74ea07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boni=20Garc=C3=ADa?= Date: Sat, 16 Sep 2023 04:00:41 +0200 Subject: [PATCH 075/141] [rust] Use original path when unwrap fails in canonicalize function (#12699) --- rust/src/lib.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 20c2bea78e505..bbb4c415cb011 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -935,13 +935,7 @@ pub trait SeleniumManager { } fn canonicalize_path(&self, path_buf: PathBuf) -> String { - let canon_path = path_buf - .as_path() - .canonicalize() - .unwrap() - .to_str() - .unwrap() - .to_string(); + let canon_path = path_buf_to_string(path_buf.as_path().canonicalize().unwrap_or(path_buf)); if WINDOWS.is(self.get_os()) { canon_path.replace(UNC_PREFIX, "") } else { From 14e43b158a3ae4846e67d74f0ec17f72c9187e2b Mon Sep 17 00:00:00 2001 From: Titus Fortner Date: Fri, 15 Sep 2023 21:06:50 -0500 Subject: [PATCH 076/141] [py] do not send parameters in payload that are used in endpoint (#12685) --- py/selenium/webdriver/remote/remote_connection.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/py/selenium/webdriver/remote/remote_connection.py b/py/selenium/webdriver/remote/remote_connection.py index 1bc6ec5f4c41c..870d51d511f59 100644 --- a/py/selenium/webdriver/remote/remote_connection.py +++ b/py/selenium/webdriver/remote/remote_connection.py @@ -286,9 +286,12 @@ def execute(self, command, params): """ command_info = self._commands[command] assert command_info is not None, f"Unrecognised command {command}" - path = string.Template(command_info[1]).substitute(params) - if isinstance(params, dict) and "sessionId" in params: - del params["sessionId"] + path_string = command_info[1] + path = string.Template(path_string).substitute(params) + substitute_params = {word[1:] for word in path_string.split("/") if word.startswith("$")} # remove dollar sign + if isinstance(params, dict) and substitute_params: + for word in substitute_params: + del params[word] data = utils.dump_json(params) url = f"{self._url}{path}" return self._request(command_info[0], url, body=data) From ed7ca49f152f8b91b3e3c0e040b26ce1a41ee5f8 Mon Sep 17 00:00:00 2001 From: Sean Gomez <34379448+Sean-Gomez@users.noreply.github.com> Date: Sat, 16 Sep 2023 04:50:29 -0700 Subject: [PATCH 077/141] [py] close out logging on quit (#12637) * Update webdriver to close geckodrive log_output process on quit * add conditional to close log_output whether it be type int or if it's a file-like object * [py] move closing logic to common driver service --------- Co-authored-by: titusfortner --- py/selenium/webdriver/common/service.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/py/selenium/webdriver/common/service.py b/py/selenium/webdriver/common/service.py index c6e24b0222912..6be3ecf3a2e8e 100644 --- a/py/selenium/webdriver/common/service.py +++ b/py/selenium/webdriver/common/service.py @@ -23,9 +23,9 @@ from abc import ABC from abc import abstractmethod from platform import system -from subprocess import DEVNULL from subprocess import PIPE from time import sleep +from typing import TextIO from urllib import request from urllib.error import URLError @@ -141,13 +141,12 @@ def send_remote_shutdown_command(self) -> None: def stop(self) -> None: """Stops the service.""" - if self.log_output != PIPE and not (self.log_output == DEVNULL): - try: - # Todo: Be explicit in what we are catching here. - if hasattr(self.log_output, "close"): - self.log_file.close() # type: ignore - except Exception: - pass + + if self.log_output != PIPE: + if isinstance(self.log_output, TextIO): + self.log_output.close() + elif isinstance(self.log_output, int): + os.close(self.log_output) if self.process is not None: try: From d78a8ec61a8c8a9e2551ed83dfdf6b3ab4da837c Mon Sep 17 00:00:00 2001 From: Jiahua Fan Date: Sat, 16 Sep 2023 06:52:44 -0500 Subject: [PATCH 078/141] [py] disable console appearing on windows when running in pythonw (#12715) Co-authored-by: JefferyVin --- py/selenium/webdriver/common/service.py | 36 ++++++++++++++++++------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/py/selenium/webdriver/common/service.py b/py/selenium/webdriver/common/service.py index 6be3ecf3a2e8e..4f031bea2e4eb 100644 --- a/py/selenium/webdriver/common/service.py +++ b/py/selenium/webdriver/common/service.py @@ -202,16 +202,32 @@ def _start_process(self, path: str) -> None: cmd.extend(self.command_line_args()) close_file_descriptors = self.popen_kw.pop("close_fds", system() != "Windows") try: - self.process = subprocess.Popen( - cmd, - env=self.env, - close_fds=close_file_descriptors, - stdout=self.log_output, - stderr=self.log_output, - stdin=PIPE, - creationflags=self.creation_flags, - **self.popen_kw, - ) + if system() == "Windows": + si = subprocess.STARTUPINFO() + si.dwFlags = subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW + si.wShowWindow = subprocess.SW_HIDE + self.process = subprocess.Popen( + cmd, + env=self.env, + close_fds=close_file_descriptors, + stdout=self.log_output, + stderr=self.log_output, + stdin=PIPE, + creationflags=self.creation_flags, + startupinfo=si, + **self.popen_kw, + ) + else: + self.process = subprocess.Popen( + cmd, + env=self.env, + close_fds=close_file_descriptors, + stdout=self.log_output, + stderr=self.log_output, + stdin=PIPE, + creationflags=self.creation_flags, + **self.popen_kw, + ) logger.debug(f"Started executable: `{self._path}` in a child process with pid: {self.process.pid}") except TypeError: raise From 6ff7f5491bb4d17312111f5ef187102e16a14ab7 Mon Sep 17 00:00:00 2001 From: Titus Fortner Date: Sat, 16 Sep 2023 06:54:19 -0500 Subject: [PATCH 079/141] =?UTF-8?q?[java]=20fix=20bug=20for=20appium=20sub?= =?UTF-8?q?class=20that=20sets=20neither=20log=20file=20nor=20out=E2=80=A6?= =?UTF-8?q?=20(#12696)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [java] fix bug for appium subclass that sets neither log file nor output stream --- .../org/openqa/selenium/remote/service/DriverService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/remote/service/DriverService.java b/java/src/org/openqa/selenium/remote/service/DriverService.java index a34f594e5ff1a..f5313bf90ed8f 100644 --- a/java/src/org/openqa/selenium/remote/service/DriverService.java +++ b/java/src/org/openqa/selenium/remote/service/DriverService.java @@ -444,8 +444,12 @@ protected Duration getDefaultTimeout() { } protected OutputStream getLogOutput() { + if (logOutputStream != null) { + return logOutputStream; + } try { - return logOutputStream != null ? logOutputStream : new FileOutputStream(logFile); + File logFile = getLogFile(); + return logFile == null ? ByteStreams.nullOutputStream() : new FileOutputStream(logFile); } catch (FileNotFoundException e) { throw new RuntimeException(e); } From 3e880d115ef4f505cc3509a3fbe9a38f23b3f86c Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sat, 16 Sep 2023 12:38:02 -0500 Subject: [PATCH 080/141] [js] ignore computed label test for chrome There is a bug in chrome fixed in 118 --- .../test/elementAccessibleName_test.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/javascript/node/selenium-webdriver/test/elementAccessibleName_test.js b/javascript/node/selenium-webdriver/test/elementAccessibleName_test.js index ff561d76f7e8d..11994fb162acc 100644 --- a/javascript/node/selenium-webdriver/test/elementAccessibleName_test.js +++ b/javascript/node/selenium-webdriver/test/elementAccessibleName_test.js @@ -19,7 +19,8 @@ const assert = require('assert') const test = require('../lib/test') -const { By } = require('../index') +const { By, Browser } = require('../index') +const { ignore } = require('../lib/test') test.suite( function (env) { @@ -45,16 +46,19 @@ test.suite( assert.strictEqual(await imgLabel.getAccessibleName(), 'Test Image') }) - it('Should return computed label for label', async function () { - await driver.get(`data:text/html, + ignore(env.browsers(Browser.CHROME)).it( + 'Should return computed label for label', + async function () { + await driver.get(`data:text/html, `) - let computedLabel = driver.findElement(By.css('input')) - assert.strictEqual( - await computedLabel.getAccessibleName(), - 'Test Label' - ) - }) + let computedLabel = driver.findElement(By.css('input')) + assert.strictEqual( + await computedLabel.getAccessibleName(), + 'Test Label' + ) + } + ) it('Should return computed label for aria-label', async function () { await driver.get(`data:text/html, From da4eaa135358154f7607aae6a827973a38cc223b Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sat, 16 Sep 2023 13:00:42 -0500 Subject: [PATCH 081/141] [js] fix tests; navigationId should not be null --- javascript/node/selenium-webdriver/test/bidi/bidi_test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/javascript/node/selenium-webdriver/test/bidi/bidi_test.js b/javascript/node/selenium-webdriver/test/bidi/bidi_test.js index 88678d8f95b89..0a4ef823a41b1 100644 --- a/javascript/node/selenium-webdriver/test/bidi/bidi_test.js +++ b/javascript/node/selenium-webdriver/test/bidi/bidi_test.js @@ -348,7 +348,7 @@ suite( let info = await browsingContext.navigate(Pages.logEntryAdded) assert.notEqual(browsingContext.id, null) - assert.equal(info.navigationId, null) + assert.notEqual(info.navigationId, null) assert(info.url.includes('/bidi/logEntryAdded.html')) }) @@ -363,7 +363,7 @@ suite( ) assert.notEqual(browsingContext.id, null) - assert.equal(info.navigationId, null) + assert.notEqual(info.navigationId, null) assert(info.url.includes('/bidi/logEntryAdded.html')) }) @@ -1962,7 +1962,7 @@ suite( const info = await browsingContext.navigate(Pages.logEntryAdded) assert.notEqual(browsingContext.id, null) - assert.equal(info.navigationId, null) + assert.notEqual(info.navigationId, null) assert(info.url.includes('/bidi/logEntryAdded.html')) await driver.wait(until.urlIs(Pages.logEntryAdded)) From 34e03ad7af446294a2966fee28f11fc897895dc4 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sat, 16 Sep 2023 13:10:05 -0500 Subject: [PATCH 082/141] [js] fix linter issues --- javascript/node/selenium-webdriver/chrome.js | 7 +++++- .../node/selenium-webdriver/chromium.js | 12 ++++++---- .../common/seleniumManager.js | 22 +++++++++---------- javascript/node/selenium-webdriver/firefox.js | 6 ++--- javascript/node/selenium-webdriver/lib/by.js | 6 ++++- .../selenium-webdriver/lib/test/fileserver.js | 2 +- .../node/selenium-webdriver/remote/util.js | 6 ++++- .../selenium-webdriver/test/upload_test.js | 4 ++-- 8 files changed, 40 insertions(+), 25 deletions(-) diff --git a/javascript/node/selenium-webdriver/chrome.js b/javascript/node/selenium-webdriver/chrome.js index 77e14cf6eb1e4..9b39e7f3f72b8 100644 --- a/javascript/node/selenium-webdriver/chrome.js +++ b/javascript/node/selenium-webdriver/chrome.js @@ -221,7 +221,12 @@ class Driver extends chromium.Driver { static createSession(opt_config, opt_serviceExecutor) { let caps = opt_config || new Options() return /** @type {!Driver} */ ( - super.createSession(caps, opt_serviceExecutor, 'goog', CHROME_CAPABILITY_KEY) + super.createSession( + caps, + opt_serviceExecutor, + 'goog', + CHROME_CAPABILITY_KEY + ) ) } diff --git a/javascript/node/selenium-webdriver/chromium.js b/javascript/node/selenium-webdriver/chromium.js index d9aa404e31fb0..ad8899905373f 100644 --- a/javascript/node/selenium-webdriver/chromium.js +++ b/javascript/node/selenium-webdriver/chromium.js @@ -679,8 +679,12 @@ class Driver extends webdriver.WebDriver { * @param vendorCapabilityKey Either 'goog:chromeOptions' or 'ms:edgeOptions' * @return {!Driver} A new driver instance. */ - static createSession(caps, opt_serviceExecutor, - vendorPrefix = '', vendorCapabilityKey = '') { + static createSession( + caps, + opt_serviceExecutor, + vendorPrefix = '', + vendorCapabilityKey = '' + ) { let executor let onQuit if (opt_serviceExecutor instanceof http.Executor) { @@ -689,14 +693,14 @@ class Driver extends webdriver.WebDriver { } else { let service = opt_serviceExecutor || this.getDefaultService() if (!service.getExecutable()) { - const {driverPath, browserPath} = getPath(caps) + const { driverPath, browserPath } = getPath(caps) service.setExecutable(driverPath) const vendorOptions = caps.get(vendorCapabilityKey) if (vendorOptions) { vendorOptions['binary'] = browserPath caps.set(vendorCapabilityKey, vendorOptions) } else { - caps.set(vendorCapabilityKey, {binary: browserPath}) + caps.set(vendorCapabilityKey, { binary: browserPath }) } } onQuit = () => service.kill() diff --git a/javascript/node/selenium-webdriver/common/seleniumManager.js b/javascript/node/selenium-webdriver/common/seleniumManager.js index 7d3f0bb677755..aaf9c1ef6ae03 100644 --- a/javascript/node/selenium-webdriver/common/seleniumManager.js +++ b/javascript/node/selenium-webdriver/common/seleniumManager.js @@ -27,7 +27,7 @@ const fs = require('fs') const spawnSync = require('child_process').spawnSync const { Capability } = require('../lib/capabilities') -let debugMessagePrinted = false; +let debugMessagePrinted = false /** * Determines the path of the correct Selenium Manager binary @@ -49,12 +49,12 @@ function getBinary() { const filePath = path.join(seleniumManagerBasePath, directory, file) if (!fs.existsSync(filePath)) { - throw new Error(`Unable to obtain Selenium Manager`) + throw new Error(`Unable to obtain Selenium Manager at ${filePath}`) } if (!debugMessagePrinted) { console.debug(`Selenium Manager binary found at ${filePath}`) - debugMessagePrinted = true; // Set the flag to true after printing the debug message + debugMessagePrinted = true // Set the flag to true after printing the debug message } return filePath @@ -82,19 +82,17 @@ function driverLocation(options) { args.push('--browser-path', path.resolve(vendorOptions.binary)) } - const proxyOptions = options.getProxy(); + const proxyOptions = options.getProxy() // Check if proxyOptions exists and has properties if (proxyOptions && Object.keys(proxyOptions).length > 0) { - const httpProxy = proxyOptions['httpProxy']; - const sslProxy = proxyOptions['sslProxy']; + const httpProxy = proxyOptions['httpProxy'] + const sslProxy = proxyOptions['sslProxy'] if (httpProxy !== undefined) { - args.push('--proxy', httpProxy); - } - - else if (sslProxy !== undefined) { - args.push('--proxy', sslProxy); + args.push('--proxy', httpProxy) + } else if (sslProxy !== undefined) { + args.push('--proxy', sslProxy) } } @@ -139,7 +137,7 @@ function driverLocation(options) { } } -function logOutput (output) { +function logOutput(output) { for (const key in output.logs) { if (output.logs[key].level === 'WARN') { console.warn(`${output.logs[key].message}`) diff --git a/javascript/node/selenium-webdriver/firefox.js b/javascript/node/selenium-webdriver/firefox.js index 569ed515903ff..4ff1983ddceab 100644 --- a/javascript/node/selenium-webdriver/firefox.js +++ b/javascript/node/selenium-webdriver/firefox.js @@ -591,7 +591,7 @@ class Driver extends webdriver.WebDriver { configureExecutor(executor) } else if (opt_executor instanceof remote.DriverService) { if (!opt_executor.getExecutable()) { - const {driverPath, browserPath} = getPath(caps) + const { driverPath, browserPath } = getPath(caps) opt_executor.setExecutable(driverPath) firefoxBrowserPath = browserPath } @@ -600,7 +600,7 @@ class Driver extends webdriver.WebDriver { } else { let service = new ServiceBuilder().build() if (!service.getExecutable()) { - const {driverPath, browserPath} = getPath(caps) + const { driverPath, browserPath } = getPath(caps) service.setExecutable(driverPath) firefoxBrowserPath = browserPath } @@ -614,7 +614,7 @@ class Driver extends webdriver.WebDriver { vendorOptions['binary'] = firefoxBrowserPath caps.set(FIREFOX_CAPABILITY_KEY, vendorOptions) } else { - caps.set(FIREFOX_CAPABILITY_KEY, {binary: firefoxBrowserPath}) + caps.set(FIREFOX_CAPABILITY_KEY, { binary: firefoxBrowserPath }) } } diff --git a/javascript/node/selenium-webdriver/lib/by.js b/javascript/node/selenium-webdriver/lib/by.js index fcc4304780d9f..022ec4bdd8a20 100644 --- a/javascript/node/selenium-webdriver/lib/by.js +++ b/javascript/node/selenium-webdriver/lib/by.js @@ -396,7 +396,11 @@ class RelativeBy { * strategy. */ function check(locator) { - if (locator instanceof By || locator instanceof RelativeBy || typeof locator === 'function') { + if ( + locator instanceof By || + locator instanceof RelativeBy || + typeof locator === 'function' + ) { return locator } diff --git a/javascript/node/selenium-webdriver/lib/test/fileserver.js b/javascript/node/selenium-webdriver/lib/test/fileserver.js index acf7fdd3f571f..53051a72a3eaf 100644 --- a/javascript/node/selenium-webdriver/lib/test/fileserver.js +++ b/javascript/node/selenium-webdriver/lib/test/fileserver.js @@ -264,7 +264,7 @@ function handleUpload(request, response) { .contentType('html') .send( files.join('\n') + - '\n' + '\n' ) } }) diff --git a/javascript/node/selenium-webdriver/remote/util.js b/javascript/node/selenium-webdriver/remote/util.js index 908968623e700..2cc52eed6250b 100644 --- a/javascript/node/selenium-webdriver/remote/util.js +++ b/javascript/node/selenium-webdriver/remote/util.js @@ -37,7 +37,11 @@ function getJavaPath() { function isSelenium3x(seleniumStandalonePath) { const javaPath = getJavaPath() - const execRes = cp.execFileSync(javaPath, ['-jar', seleniumStandalonePath, '--version']) + const execRes = cp.execFileSync(javaPath, [ + '-jar', + seleniumStandalonePath, + '--version', + ]) return execRes.toString().trim().startsWith('Selenium server version: 3') } diff --git a/javascript/node/selenium-webdriver/test/upload_test.js b/javascript/node/selenium-webdriver/test/upload_test.js index 6686477592c05..f6ac3130b5199 100644 --- a/javascript/node/selenium-webdriver/test/upload_test.js +++ b/javascript/node/selenium-webdriver/test/upload_test.js @@ -29,7 +29,7 @@ const Pages = test.Pages test.suite(function (env) { var LOREM_IPSUM_TEXT = 'lorem ipsum dolor sit amet' var FILE_HTML = '
' + LOREM_IPSUM_TEXT + '
' - var FILE_HTML_2 = '
' + "I love sausages too" + '
' + var FILE_HTML_2 = '
' + 'I love sausages too' + '
' var _fp before(function () { @@ -109,7 +109,7 @@ test.suite(function (env) { var frame = await driver.findElement(By.id('upload_target')) await driver.switchTo().frame(frame) - const txt = await driver.findElement(By.css('body')).getText(); + const txt = await driver.findElement(By.css('body')).getText() assert.strictEqual( txt, fp.split('/').pop(), From 28665786d4be8a81c1f73bfa33847e810b8081cd Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sat, 16 Sep 2023 14:22:20 -0500 Subject: [PATCH 083/141] [js] fix flaky tests --- javascript/node/selenium-webdriver/test/firefox_test.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/javascript/node/selenium-webdriver/test/firefox_test.js b/javascript/node/selenium-webdriver/test/firefox_test.js index 572e238c721d6..e65c41d70eaa7 100644 --- a/javascript/node/selenium-webdriver/test/firefox_test.js +++ b/javascript/node/selenium-webdriver/test/firefox_test.js @@ -26,6 +26,7 @@ const { Browser } = require('../') const { Context } = require('../firefox') const { Pages, suite } = require('../lib/test') const { locate } = require('../lib/test/resources') +const { until, By } = require('../index') const EXT_XPI = locate('common/extensions/webextensions-selenium-example.xpi') const EXT_UNSIGNED_ZIP = locate( @@ -320,9 +321,11 @@ suite( } async function verifyWebExtensionWasInstalled() { - let footer = await driver.findElement({ - id: 'webextensions-selenium-example', - }) + let footer = await driver.wait( + until.elementLocated(By.id('webextensions-selenium-example')), + 5000 + ) + let text = await footer.getText() assert.strictEqual( text, From 0fd2532cef0a49b7ee928bb3d5b95c3f161b84b4 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sat, 16 Sep 2023 14:23:57 -0500 Subject: [PATCH 084/141] [js] fix more lint warnings --- javascript/node/selenium-webdriver/chrome.js | 1 - javascript/node/selenium-webdriver/remote/index.js | 1 - javascript/node/selenium-webdriver/test/bidi/bidi_test.js | 1 - .../node/selenium-webdriver/test/chrome/devtools_test.js | 7 +------ 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/javascript/node/selenium-webdriver/chrome.js b/javascript/node/selenium-webdriver/chrome.js index 9b39e7f3f72b8..22f04471b82c8 100644 --- a/javascript/node/selenium-webdriver/chrome.js +++ b/javascript/node/selenium-webdriver/chrome.js @@ -127,7 +127,6 @@ 'use strict' -const io = require('./io') const { Browser } = require('./lib/capabilities') const chromium = require('./chromium') const CHROME_CAPABILITY_KEY = 'goog:chromeOptions' diff --git a/javascript/node/selenium-webdriver/remote/index.js b/javascript/node/selenium-webdriver/remote/index.js index 025876c1db95f..8d826793487df 100644 --- a/javascript/node/selenium-webdriver/remote/index.js +++ b/javascript/node/selenium-webdriver/remote/index.js @@ -17,7 +17,6 @@ 'use strict' -const fs = require('fs') const url = require('url') const httpUtil = require('../http/util') diff --git a/javascript/node/selenium-webdriver/test/bidi/bidi_test.js b/javascript/node/selenium-webdriver/test/bidi/bidi_test.js index 0a4ef823a41b1..50d7d4f8edf1f 100644 --- a/javascript/node/selenium-webdriver/test/bidi/bidi_test.js +++ b/javascript/node/selenium-webdriver/test/bidi/bidi_test.js @@ -1265,7 +1265,6 @@ suite( it('can evaluate in a realm', async function () { const firstTab = await driver.getWindowHandle() await driver.switchTo().newWindow('tab') - const secondTab = await driver.getWindowHandle() const manager = await ScriptManager(firstTab, driver) const realms = await manager.getAllRealms() diff --git a/javascript/node/selenium-webdriver/test/chrome/devtools_test.js b/javascript/node/selenium-webdriver/test/chrome/devtools_test.js index 1f90c7f533603..c98515a7ce560 100644 --- a/javascript/node/selenium-webdriver/test/chrome/devtools_test.js +++ b/javascript/node/selenium-webdriver/test/chrome/devtools_test.js @@ -289,12 +289,7 @@ test.suite( await assertAsyncScriptPinned(() => driver.executeAsyncScript(script)) async function assertAsyncScriptPinned(fn) { - try { - await fn() - return - } catch (err) { - throw err - } + await fn() } }) }) From c80ce4d2874efaaec8cbb3a745fa83e8d69fc55d Mon Sep 17 00:00:00 2001 From: Sandeep Suryaprasad <26169602+sandeepsuryaprasad@users.noreply.github.com> Date: Sun, 17 Sep 2023 05:59:19 +0530 Subject: [PATCH 085/141] [py] refactored by removing duplicate code in PR12715 (#12755) --- py/selenium/webdriver/common/service.py | 41 ++++++++++--------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/py/selenium/webdriver/common/service.py b/py/selenium/webdriver/common/service.py index 4f031bea2e4eb..4a20ae00b8be1 100644 --- a/py/selenium/webdriver/common/service.py +++ b/py/selenium/webdriver/common/service.py @@ -202,32 +202,23 @@ def _start_process(self, path: str) -> None: cmd.extend(self.command_line_args()) close_file_descriptors = self.popen_kw.pop("close_fds", system() != "Windows") try: + start_info = None if system() == "Windows": - si = subprocess.STARTUPINFO() - si.dwFlags = subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW - si.wShowWindow = subprocess.SW_HIDE - self.process = subprocess.Popen( - cmd, - env=self.env, - close_fds=close_file_descriptors, - stdout=self.log_output, - stderr=self.log_output, - stdin=PIPE, - creationflags=self.creation_flags, - startupinfo=si, - **self.popen_kw, - ) - else: - self.process = subprocess.Popen( - cmd, - env=self.env, - close_fds=close_file_descriptors, - stdout=self.log_output, - stderr=self.log_output, - stdin=PIPE, - creationflags=self.creation_flags, - **self.popen_kw, - ) + start_info = subprocess.STARTUPINFO() + start_info.dwFlags = subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW + start_info.wShowWindow = subprocess.SW_HIDE + + self.process = subprocess.Popen( + cmd, + env=self.env, + close_fds=close_file_descriptors, + stdout=self.log_output, + stderr=self.log_output, + stdin=PIPE, + creationflags=self.creation_flags, + startupinfo=start_info, + **self.popen_kw, + ) logger.debug(f"Started executable: `{self._path}` in a child process with pid: {self.process.pid}") except TypeError: raise From 61f6122e5e1db1aecd7d64c622ac9b3ce734e798 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sat, 16 Sep 2023 21:42:22 -0500 Subject: [PATCH 086/141] [dotnet] fix flaky test --- dotnet/test/common/PositionAndSizeTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dotnet/test/common/PositionAndSizeTest.cs b/dotnet/test/common/PositionAndSizeTest.cs index fe45ff81b7206..c4c0a9f5395f1 100644 --- a/dotnet/test/common/PositionAndSizeTest.cs +++ b/dotnet/test/common/PositionAndSizeTest.cs @@ -139,12 +139,12 @@ public void ShouldHandleNonIntegerPositionAndSize() string left = r2.GetCssValue("left"); Assert.AreEqual(Math.Round(Convert.ToDecimal(left.Replace("px", "")), 1), 10.9); string top = r2.GetCssValue("top"); - Assert.That(top, Does.StartWith("10.1")); + Assert.AreEqual(Math.Round(Convert.ToDecimal(top.Replace("px", "")), 1), 10.1); Assert.AreEqual(new Point(11, 10), r2.Location); string width = r2.GetCssValue("width"); - Assert.That(width, Does.StartWith("48.6")); + Assert.AreEqual(Math.Round(Convert.ToDecimal(width.Replace("px", "")), 1), 48.6); string height = r2.GetCssValue("height"); - Assert.That(height, Does.StartWith("49.3")); + Assert.AreEqual(Math.Round(Convert.ToDecimal(height.Replace("px", "")), 1), 49.3); Assert.AreEqual(r2.Size, new Size(49, 49)); } From 0f1640daed5c2a3c1e5a244b67e2a822014fc6c2 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Fri, 15 Sep 2023 16:25:35 -0500 Subject: [PATCH 087/141] [cdp] add pdl files for Chrome 117 and remove 114 --- .../chromium/{v114 => v117}/BUILD.bazel | 0 .../{v114 => v117}/browser_protocol.pdl | 486 +++++++++++++++--- .../chromium/{v114 => v117}/js_protocol.pdl | 59 ++- 3 files changed, 465 insertions(+), 80 deletions(-) rename common/devtools/chromium/{v114 => v117}/BUILD.bazel (100%) rename common/devtools/chromium/{v114 => v117}/browser_protocol.pdl (95%) rename common/devtools/chromium/{v114 => v117}/js_protocol.pdl (95%) diff --git a/common/devtools/chromium/v114/BUILD.bazel b/common/devtools/chromium/v117/BUILD.bazel similarity index 100% rename from common/devtools/chromium/v114/BUILD.bazel rename to common/devtools/chromium/v117/BUILD.bazel diff --git a/common/devtools/chromium/v114/browser_protocol.pdl b/common/devtools/chromium/v117/browser_protocol.pdl similarity index 95% rename from common/devtools/chromium/v114/browser_protocol.pdl rename to common/devtools/chromium/v117/browser_protocol.pdl index 17c0dd3b7f21d..b945d1ed62ed2 100644 --- a/common/devtools/chromium/v114/browser_protocol.pdl +++ b/common/devtools/chromium/v117/browser_protocol.pdl @@ -72,7 +72,7 @@ experimental domain Accessibility optional AXValue attributeValue # Whether this source is superseded by a higher priority source. optional boolean superseded - # The native markup source for this value, e.g. a