Skip to content

Commit

Permalink
Merge branch 'trunk' into dotnet-logfile-overwite
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol authored May 9, 2024
2 parents 7274501 + 67ba005 commit 92e09ec
Show file tree
Hide file tree
Showing 61 changed files with 569 additions and 230 deletions.
2 changes: 1 addition & 1 deletion .bazelrc.remote
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ test:remote --test_env=PATH=/bin:/usr/bin:/usr/local/bin
test:remote --test_env=HOME=/home/dev

# Make sure we sniff credentials properly
build:remote --credential_helper=%workspace%/scripts/credential-helper.sh
build:remote --credential_helper=gypsum.cluster.engflow.com=%workspace%/scripts/credential-helper.sh

# Use pinned browsers when running remotely
build:remote --//common:pin_browsers
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.1.0
7.1.1
5 changes: 0 additions & 5 deletions .github/workflows/ci-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ jobs:
os: ubuntu
- browser: safari
os: windows
# TODO: Investigate why they are timing out
- browser: chrome
os: windows
- browser: edge
os: windows
with:
name: Local Tests (${{ matrix.browser }}, ${{ matrix.os }})
browser: ${{ matrix.browser }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ bazel-genfiles
bazel-out
bazel-selenium
bazel-testlogs
MODULE.bazel.lock

/.vscode/
/.scannerwork/
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bazel_dep(name = "contrib_rules_jvm", version = "0.24.0")
bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "rules_dotnet", version = "0.14.0")
bazel_dep(name = "rules_java", version = "7.4.0")
bazel_dep(name = "rules_jvm_external", version = "6.0")
bazel_dep(name = "rules_jvm_external", version = "6.1")
bazel_dep(name = "rules_nodejs", version = "6.0.5")
bazel_dep(name = "rules_oci", version = "1.0.0")
bazel_dep(name = "rules_pkg", version = "0.9.1")
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ Supported browsers:
* `safari-preview`

In addition to the [Common Options Examples](#common-options-examples), here are some additional Ruby specific ones:
* `--test_arg "-tfocus"` - test only [focused specs](https://relishapp.com/rspec/rspec-core/v/3-12/docs/filtering/inclusion-filters)
* `--test_arg "-eTimeouts"` - test only specs which name include "Timeouts"
* `--test_arg "<any other RSpec argument>"` - pass any extra RSpec arguments (see `bazel run @bundle//bin:rspec -- --help`)

Expand Down
42 changes: 21 additions & 21 deletions common/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ js_library(

http_archive(
name = "linux_beta_firefox",
url = "https://ftp.mozilla.org/pub/firefox/releases/126.0b7/linux-x86_64/en-US/firefox-126.0b7.tar.bz2",
sha256 = "a7bd26d05857ffb08e46af9016973c74d16be806025a6329bb843dffde0672f9",
url = "https://ftp.mozilla.org/pub/firefox/releases/126.0b9/linux-x86_64/en-US/firefox-126.0b9.tar.bz2",
sha256 = "053e60089c6ab85507dca96ad8c9d32e3fc6d21ac5bdf7e616c673327804565f",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -72,8 +72,8 @@ js_library(

dmg_archive(
name = "mac_beta_firefox",
url = "https://ftp.mozilla.org/pub/firefox/releases/126.0b7/mac/en-US/Firefox%20126.0b7.dmg",
sha256 = "f98f772c94addfb05f2c1abe851938b2f806794af0104c73d51445132fa0855c",
url = "https://ftp.mozilla.org/pub/firefox/releases/126.0b9/mac/en-US/Firefox%20126.0b9.dmg",
sha256 = "67806b532db26059fbe747ec3fc2f6306d9bb4b09e1b264c49461c4d613b5366",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand Down Expand Up @@ -123,10 +123,10 @@ js_library(

pkg_archive(
name = "mac_edge",
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/8325266a-e5ef-4b92-b110-6e387417723c/MicrosoftEdge-124.0.2478.67.pkg",
sha256 = "4c79de91852bda6a779761d06cfa00d48ae4f08dfe3903543f3674b973bd780b",
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/e6f7f9ba-499c-44cb-9c19-28daeaa82dc6/MicrosoftEdge-124.0.2478.80.pkg",
sha256 = "fc667b0401c05bbe0e4d337cc593641e2b653107fafd363b401cd32baa8a4f53",
move = {
"MicrosoftEdge-124.0.2478.67.pkg/Payload/Microsoft Edge.app": "Edge.app",
"MicrosoftEdge-124.0.2478.80.pkg/Payload/Microsoft Edge.app": "Edge.app",
},
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
Expand All @@ -143,8 +143,8 @@ js_library(

deb_archive(
name = "linux_edge",
url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_124.0.2478.67-1_amd64.deb",
sha256 = "3d12f66a279b0a82b478625696f23e1ac935e0596d57e19a41da232ee0c58a65",
url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_124.0.2478.80-1_amd64.deb",
sha256 = "a7eb75d95730c520eec998f755fcc427a9b4ac6a150bbb267b21e8383b6dc105",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -165,8 +165,8 @@ js_library(

http_archive(
name = "linux_edgedriver",
url = "https://msedgedriver.azureedge.net/124.0.2478.67/edgedriver_linux64.zip",
sha256 = "25a169807beb4fc2485cf601f04c76cfffcc2c1e23a875941bc8aa41bee0587c",
url = "https://msedgedriver.azureedge.net/124.0.2478.80/edgedriver_linux64.zip",
sha256 = "4c9192c8e42ac1e1d779784ba95a0b28807cc75ae1be07be740f40bc20410670",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -182,8 +182,8 @@ js_library(

http_archive(
name = "mac_edgedriver",
url = "https://msedgedriver.azureedge.net/124.0.2478.67/edgedriver_mac64.zip",
sha256 = "571d910bc662e2dfcf10e47cf40d11f76568b893abbde877f2beb487693ed983",
url = "https://msedgedriver.azureedge.net/124.0.2478.80/edgedriver_mac64.zip",
sha256 = "f8d8b0eaacb884196e5f368a64cad246a86e5a92941b0d37c5d7aa8ebb0fec1f",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -199,8 +199,8 @@ js_library(

http_archive(
name = "linux_chrome",
url = "https://storage.googleapis.com/chrome-for-testing-public/124.0.6367.91/linux64/chrome-linux64.zip",
sha256 = "035b3bce9748423b3d0c3f74fc6ff0f1a5b29a6454eff74565bab10af7397b75",
url = "https://storage.googleapis.com/chrome-for-testing-public/124.0.6367.155/linux64/chrome-linux64.zip",
sha256 = "0761489e320bb56a29f53c051abea0a26418afcef62af2fa9bf1d4768a78d005",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -221,8 +221,8 @@ js_library(

http_archive(
name = "mac_chrome",
url = "https://storage.googleapis.com/chrome-for-testing-public/124.0.6367.91/mac-x64/chrome-mac-x64.zip",
sha256 = "729da107fadce00d7d1f60347a9e5276f6fdec5d0131a7f551d3297261ed1dd8",
url = "https://storage.googleapis.com/chrome-for-testing-public/124.0.6367.155/mac-x64/chrome-mac-x64.zip",
sha256 = "30456654c6699f2b8b6378a08d82caff439da1834213cb65e3536e669fc0e7ad",
strip_prefix = "chrome-mac-x64",
patch_cmds = [
"mv 'Google Chrome for Testing.app' Chrome.app",
Expand All @@ -243,8 +243,8 @@ js_library(

http_archive(
name = "linux_chromedriver",
url = "https://storage.googleapis.com/chrome-for-testing-public/124.0.6367.91/linux64/chromedriver-linux64.zip",
sha256 = "c70691361eec965c8d6aaf3e68b0190d0dee0e0d3a72edca62a734d8b58f4b2c",
url = "https://storage.googleapis.com/chrome-for-testing-public/124.0.6367.155/linux64/chromedriver-linux64.zip",
sha256 = "7ae76046edce32e4c14de5fcceb9ba4a18268dcb0d87368160400fff89f54899",
strip_prefix = "chromedriver-linux64",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
Expand All @@ -261,8 +261,8 @@ js_library(

http_archive(
name = "mac_chromedriver",
url = "https://storage.googleapis.com/chrome-for-testing-public/124.0.6367.91/mac-x64/chromedriver-mac-x64.zip",
sha256 = "44638284ae0986b15481563fe58aa01342852d197a6bb5f6965c3565f8623d76",
url = "https://storage.googleapis.com/chrome-for-testing-public/124.0.6367.155/mac-x64/chromedriver-mac-x64.zip",
sha256 = "e0c6700f68e08ceac14ed923c56d171fe9597cff308fb67a7a0ecbc05ce208f5",
strip_prefix = "chromedriver-mac-x64",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
Expand Down
14 changes: 14 additions & 0 deletions common/src/web/select_space.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Multiple Selection test page</title>
</head>
<body>
<select id="selectWithoutMultiple">
<option value="one">one</option>
<option value="two">&nbsp;&nbsp;two</option>
<option value="three">&nbsp;&nbsp;&nbsp;three</option>
<option value="four">&nbsp;&nbsp;&nbsp;&nbsp;four</option>
<option value="five">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;five</option>
</body>
</html>
7 changes: 5 additions & 2 deletions java/src/org/openqa/selenium/chromium/ChromiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,16 @@ public Optional<DevTools> maybeGetDevTools() {
}

private Optional<BiDi> createBiDi(Optional<URI> biDiUri) {
if (!biDiUri.isPresent()) {
if (biDiUri.isEmpty()) {
return Optional.empty();
}

URI wsUri =
biDiUri.orElseThrow(
() -> new BiDiException("This version of Chromium driver does not support BiDi"));
() ->
new BiDiException(
"Check if this browser version supports BiDi and if the 'webSocketUrl: true'"
+ " capability is set."));

HttpClient.Factory clientFactory = HttpClient.Factory.createDefault();
ClientConfig wsConfig = ClientConfig.defaultConfig().baseUri(wsUri);
Expand Down
29 changes: 17 additions & 12 deletions java/src/org/openqa/selenium/devtools/CdpClientGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -913,18 +913,23 @@ public TypeDeclaration<?> toTypeDeclaration() {
fromJson.getBody().get().addStatement(String.format("return new %s(%s);", name, getMapper()));

MethodDeclaration toJson = classDecl.addMethod("toJson").setPublic(true);
if (type.equals("object")) {
toJson.setType("java.util.Map<String, Object>");
toJson.getBody().get().addStatement(String.format("return %s;", propertyName));
} else if (type.equals("number")) {
toJson.setType(Number.class);
toJson.getBody().get().addStatement(String.format("return %s;", propertyName));
} else if (type.equals("integer")) {
toJson.setType(Integer.class);
toJson.getBody().get().addStatement(String.format("return %s;", propertyName));
} else {
toJson.setType(String.class);
toJson.getBody().get().addStatement(String.format("return %s.toString();", propertyName));
switch (type) {
case "object":
toJson.setType("java.util.Map<String, Object>");
toJson.getBody().get().addStatement(String.format("return %s;", propertyName));
break;
case "number":
toJson.setType(Number.class);
toJson.getBody().get().addStatement(String.format("return %s;", propertyName));
break;
case "integer":
toJson.setType(Integer.class);
toJson.getBody().get().addStatement(String.format("return %s;", propertyName));
break;
default:
toJson.setType(String.class);
toJson.getBody().get().addStatement(String.format("return %s.toString();", propertyName));
break;
}

MethodDeclaration toString = classDecl.addMethod("toString").setPublic(true);
Expand Down
29 changes: 29 additions & 0 deletions java/src/org/openqa/selenium/devtools/RequestFailedException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.devtools;

import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.http.Filter;
import org.openqa.selenium.remote.http.HttpHandler;

/**
* This exception is thrown by the final {@link HttpHandler} in a {@link Filter} chain when the
* browser fails to send a HTTP request. It can be caught in a {@link Filter} to handle the error
* by, for example, returning a custom HTTP response.
*/
public class RequestFailedException extends WebDriverException {}
18 changes: 16 additions & 2 deletions java/src/org/openqa/selenium/devtools/idealized/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.openqa.selenium.devtools.DevToolsException;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.NetworkInterceptor;
import org.openqa.selenium.devtools.RequestFailedException;
import org.openqa.selenium.internal.Either;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.http.Contents;
Expand Down Expand Up @@ -202,8 +203,12 @@ public void prepareToInterceptTraffic() {
String id = getRequestId(pausedRequest);

if (hasErrorResponse(pausedRequest)) {
pendingResponses.remove(id);
devTools.send(continueWithoutModification(pausedRequest));
CompletableFuture<HttpResponse> future = pendingResponses.remove(id);
if (future == null) {
devTools.send(continueWithoutModification(pausedRequest));
} else {
future.completeExceptionally(new RequestFailedException());
}
return;
}

Expand Down Expand Up @@ -244,6 +249,11 @@ public void prepareToInterceptTraffic() {
pendingResponses.remove(id);
return STOP_PROCESSING;
} catch (ExecutionException e) {
if (e.getCause() instanceof RequestFailedException) {
// Throwing here will give the user's filter a chance to intercept
// the failure and handle it.
throw (RequestFailedException) e.getCause();
}
if (fetchEnabled.get()) {
LOG.log(WARNING, e, () -> "Unable to process request");
}
Expand All @@ -261,6 +271,10 @@ public void prepareToInterceptTraffic() {
}

devTools.send(fulfillRequest(pausedRequest, forBrowser));
} catch (RequestFailedException e) {
// If the exception reaches here, we know the user's filter has not handled it and the
// browser should continue its normal error handling.
devTools.send(continueWithoutModification(pausedRequest));
} catch (TimeoutException e) {
if (fetchEnabled.get()) {
throw e;
Expand Down
12 changes: 8 additions & 4 deletions java/src/org/openqa/selenium/firefox/FirefoxDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,16 @@ public DevTools getDevTools() {
}

private Optional<BiDi> createBiDi(Optional<URI> biDiUri) {
if (!biDiUri.isPresent()) {
if (biDiUri.isEmpty()) {
return Optional.empty();
}

URI wsUri =
biDiUri.orElseThrow(
() ->
new BiDiException("This version of Firefox or geckodriver does not support BiDi"));
new BiDiException(
"Check if this browser version supports BiDi and if the 'webSocketUrl: true'"
+ " capability is set."));

HttpClient.Factory clientFactory = HttpClient.Factory.createDefault();
ClientConfig wsConfig = ClientConfig.defaultConfig().baseUri(wsUri);
Expand All @@ -380,8 +382,10 @@ public Optional<BiDi> maybeGetBiDi() {

@Override
public BiDi getBiDi() {
if (!biDiUri.isPresent()) {
throw new BiDiException("This version of Firefox or geckodriver does not support Bidi");
if (biDiUri.isEmpty()) {
throw new BiDiException(
"Check if this browser version supports BiDi and if the 'webSocketUrl: true' capability"
+ " is set.");
}

return maybeGetBiDi()
Expand Down
Loading

0 comments on commit 92e09ec

Please sign in to comment.