Skip to content

Commit

Permalink
Merge branch 'SeleniumHQ:trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
MASACR99 authored Mar 10, 2024
2 parents 94c8aef + 7384157 commit d7e3d74
Show file tree
Hide file tree
Showing 52 changed files with 962 additions and 694 deletions.
9 changes: 9 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://containers.dev/implementors/json_reference/

{
"name": "selenium-devcontainer",
"build": {
"dockerfile": "../scripts/dev-image/Dockerfile"
},
"runArgs": ["--name", "selenium_devcontainer"]
}
4 changes: 2 additions & 2 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
distribution: 'temurin'
- name: Setup Bazel with caching
if: inputs.caching
uses: p0deje/setup-bazel@0.6.0
uses: bazel-contrib/setup-bazel@0.8.0
with:
bazelisk-cache: true
bazelrc: common --color=yes
Expand All @@ -110,7 +110,7 @@ jobs:
repository-cache: true
- name: Setup Bazel without caching
if: inputs.caching == false
uses: p0deje/setup-bazel@0.6.0
uses: bazel-contrib/setup-bazel@0.8.0
with:
bazelrc: common --color=yes
- name: Setup Fluxbox and Xvfb
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
fetch-depth: 50
- name: Setup Bazel
uses: p0deje/setup-bazel@0.4.0
uses: bazel-contrib/setup-bazel@0.8.0
with:
bazelisk-cache: true
external-cache: |
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ jobs:
pull-requests: write # for actions/stale to close stale PRs
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue is stale because it has been open 280 days with no activity. Remove stale label or comment or this will be closed in 14 days.'
close-issue-message: 'This issue was closed because it has been stalled for 14 days with no activity.'
stale-issue-label: 'I-stale'
days-before-stale: 280
days-before-close: 14
operations-per-run: 200
- uses: actions/stale@v9
with:
close-issue-message: 'This issue was closed because we did not receive any additional information after 14 days.'
stale-issue-label: 'R-awaiting answer'
days-before-stale: -1
days-before-close: 14
labels-to-add-when-unstale: 'needs-triaging'

30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ This article is out of date, but it includes more detailed descriptions and scre
<summary>Click to see Current Windows Setup Requirements</summary>

#### Option 1: Automatic Installation from Scratch
This script will ensure a complete ready to execute developer environment.
(nothing is installed or set that is already present unless otherwise prompted)
This script will ensure a complete ready to execute developer environment.
(nothing is installed or set that is already present unless otherwise prompted)

1. Open Powershell as an Administrator
2. Execute: `Set-ExecutionPolicy Bypass -Scope Process -Force` to allow running the script in the process
3. Navigate to the directory you want to clone Selenium in, or the parent directory of an already cloned Selenium repo
3. Navigate to the directory you want to clone Selenium in, or the parent directory of an already cloned Selenium repo
4. Download and execute this script in the powershell terminal: [scripts/dev-environment-setup.ps1]`

#### Option 2: Manual Installation
Expand Down Expand Up @@ -101,16 +101,22 @@ Rather than creating your own local dev environment, GitPod provides a ready to
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/SeleniumHQ/selenium)
#### Using Dev Container
As an alternative you can build a [Dev Container](https://containers.dev/) - basically a docker container -
suitable for building and testing Selenium using the devcontainer.json in the
[.devcontainer](.devcontainer/devcontainer.json) directory. Supporting IDEs like VS Code or IntelliJ IDEA
should point you to how such a container can be created.
#### Using Docker Image
You can also build a Docker image suitable
for building and testing Selenium using the Dockerfile in the
[dev image](scripts/dev-image/Dockerfile) directory.
## Building
Selenium is built using a common build tool called [Bazel](https://bazel.build/), to
Selenium is built using a common build tool called [Bazel](https://bazel.build/), to
allow us to easily manage dependency downloads, generate required binaries, build and release packages, and execute tests;
all in a fast, efficient manner. For a more detailed discussion, read Simon Stewart's article on [Building Selenium](https://www.selenium.dev/blog/2023/building-selenium/)
Expand All @@ -119,12 +125,12 @@ Often we wrap Bazel commands with our custom [Rake](http://rake.rubyforge.org/)
The common Bazel commands are:
* `bazel build` — evaluates dependencies, compiles source files and generates output files for the specified target.
It's used to create executable binaries, libraries, or other artifacts.
* `bazel run` — builds the target and then executes it.
* `bazel run` — builds the target and then executes it.
It's typically used for targets that produce executable binaries.
* `bazel test` — builds and runs the target in a context with additional testing functionality
* `bazel query` — identifies available targets for the provided path.
Each module that can be built is defined in a `BUILD.bazel` file. To execute the module you refer to it starting with a
Each module that can be built is defined in a `BUILD.bazel` file. To execute the module you refer to it starting with a
`//`, then include the relative path to the file that defines it, then `:`, then the name of the target.
For example, the target to build the Grid is named `executable-grid` and it is
defined in the `'selenium/java/src/org/openqa/selenium/grid/BAZEL.build'` file.
Expand Down Expand Up @@ -164,7 +170,7 @@ view file from the [scripts](scripts) directory. `ij.bazelproject` for Mac/Linux

#### Linting
We also use Google Java Format for linting, so using the Google Java Formatter Plugin is useful;
there are a few steps to get it working, so read their [configuration documentation](https://github.com/google/google-java-format/blob/master/README.md#intellij-jre-config).
there are a few steps to get it working, so read their [configuration documentation](https://github.com/google/google-java-format/blob/master/README.md#intellij-jre-config).
There is also an auto-formatting script that can be run: `./scripts/format.sh`

#### Local Installation
Expand Down Expand Up @@ -208,7 +214,7 @@ If you want to debug code, you can do it via [`debug`](https://github.com/ruby/d
bazel-selenium/external/bundle/bin/rdbg -A
```

If you want to use [RubyMine](https://www.jetbrains.com/ruby/) for development,
If you want to use [RubyMine](https://www.jetbrains.com/ruby/) for development,
you can configure it use Bazel artifacts:

1. Open `rb/` as a main project directory.
Expand Down Expand Up @@ -451,9 +457,9 @@ API documentation can be found here:
* [Python](https://seleniumhq.github.io/selenium/docs/api/py/)
* [Ruby](https://seleniumhq.github.io/selenium/docs/api/rb/)

To update API documentation for a specific language: `./generate_api_docs.sh <language>`
To update API documentation for a specific language: `./go <language>:docs`

To update all documentation: `./generate_api_docs.sh all`
To update all documentation: `./go all:docs`

Note that JavaScript generation is [currently broken](https://github.com/SeleniumHQ/selenium/issues/10185).

Expand All @@ -463,7 +469,7 @@ Note that JavaScript generation is [currently broken](https://github.com/Seleniu
The full process for doing a release can be found in [the wiki](https://github.com/SeleniumHQ/selenium/wiki/Releasing-Selenium)

Releasing is a combination of building and publishing, which often requires coordination of multiple executions
and additional processing.
and additional processing.
As discussed in the [Building](#building) section, we use Rake tasks with the `./go` command for these things.
These `./go` commands include the `--stamp` argument to provide necessary information about the constructed asset.

Expand Down
20 changes: 16 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,21 @@ namespace :py do
bump_nightly = arguments[:version] === 'nightly'
old_version = python_version
new_version = nil
if bump_nightly && old_version.include?('nightly')
new_version = old_version.gsub('nightly', "#{Time.now.strftime("%Y%m%d%H%M")}")

# There are three cases we want to deal with:
# 1. Switching from a release build to a nightly one
# 2. Updating a nightly build for the next nightly build
# 3. Switching from nightlies to a release build.
# According to PEP440, the way to indicate a nightly build is `M.m.v.devN`
# Where `N` is sorted numerically. That means we can create the dev
# version number from today's date.

if bump_nightly && old_version.include?('.dev')
new_version = old_version.gsub(/\d+$/, "#{Time.now.strftime("%Y%m%d%H%M")}")
elsif bump_nightly
new_version = old_version + ".dev#{Time.now.strftime("%Y%m%d%H%M")}"
else
new_version = updated_version(old_version, arguments[:version])
new_version += '.nightly' unless old_version.include?('nightly')
new_version = updated_version(old_version.gsub(/\.dev\d+$/, ''), arguments[:version])
end

['py/setup.py',
Expand Down Expand Up @@ -711,6 +721,7 @@ namespace :rb do
task :docs, [:skip_update] do |_task, arguments|
FileUtils.rm_rf('build/docs/api/rb/')
Bazel.execute('run', [], '//rb:docs')
FileUtils.mkdir_p('build/docs/api')
FileUtils.cp_r('bazel-bin/rb/docs.rb.sh.runfiles/selenium/docs/api/rb/.', 'build/docs/api/rb')

unless arguments[:skip_update]
Expand Down Expand Up @@ -1153,6 +1164,7 @@ task :create_release_notes do
end

def updated_version(current, desired = nil)
puts "Calculating "
version = desired ? desired.split('.') : current.split(/\.|-/)
if desired
# Allows user to pass in only major/minor versions
Expand Down
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ aspect_bazel_lib_register_toolchains()

http_archive(
name = "rules_python",
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",
sha256 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311",
strip_prefix = "rules_python-0.31.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.31.0/rules_python-0.31.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_multi_toolchains")
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/v120/V120JavaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void OnRuntimeConsoleApiCalled(object sender, ConsoleAPICalledEventArgs

var wrapped = new ConsoleApiCalledEventArgs()
{
Timestamp = new DateTime(1979, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp),
Timestamp = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp),
Type = e.Type,
Arguments = args.AsReadOnly()
};
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/v121/V121JavaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void OnRuntimeConsoleApiCalled(object sender, ConsoleAPICalledEventArgs

var wrapped = new ConsoleApiCalledEventArgs()
{
Timestamp = new DateTime(1979, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp),
Timestamp = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp),
Type = e.Type,
Arguments = args.AsReadOnly()
};
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/v122/V122JavaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void OnRuntimeConsoleApiCalled(object sender, ConsoleAPICalledEventArgs

var wrapped = new ConsoleApiCalledEventArgs()
{
Timestamp = new DateTime(1979, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp),
Timestamp = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp),
Type = e.Type,
Arguments = args.AsReadOnly()
};
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/v85/V85JavaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void OnRuntimeConsoleApiCalled(object sender, ConsoleAPICalledEventArgs

var wrapped = new ConsoleApiCalledEventArgs()
{
Timestamp = new DateTime(1979, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp),
Timestamp = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp),
Type = e.Type,
Arguments = args.AsReadOnly()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Optional;
import java.util.logging.Logger;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ImmutableCapabilities;
import org.openqa.selenium.grid.config.Config;
import org.openqa.selenium.grid.config.ConfigException;
import org.openqa.selenium.grid.node.SessionFactory;
Expand Down Expand Up @@ -149,18 +150,19 @@ public Map<Capabilities, Collection<SessionFactory>> getSessionFactories(
LOG.info(String.format("Adding relay configs for %s", getServiceUri()));
parsedConfigs.forEach(
(maxSessions, stereotype) -> {
ImmutableCapabilities immutable = new ImmutableCapabilities(stereotype);
for (int i = 0; i < maxSessions; i++) {
factories.put(
stereotype,
immutable,
new RelaySessionFactory(
tracer,
clientFactory,
sessionTimeout,
getServiceUri(),
getServiceStatusUri(),
stereotype));
immutable));
}
LOG.info(String.format("Mapping %s, %d times", stereotype, maxSessions));
LOG.info(String.format("Mapping %s, %d times", immutable, maxSessions));
});
return factories.build().asMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ public boolean isServiceUp() {
// If no status endpoint was configured, we assume the server is up.
return true;
}
try {
HttpClient client = clientFactory.createClient(serviceStatusUrl);
try (HttpClient client = clientFactory.createClient(serviceStatusUrl)) {
HttpResponse response =
client.execute(new HttpRequest(HttpMethod.GET, serviceStatusUrl.toString()));
LOG.log(Debug.getDebugLogLevel(), () -> Contents.string(response));
Expand Down
11 changes: 2 additions & 9 deletions javascript/node/selenium-webdriver/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@ module.exports = {
node: true,
es6: true,
},
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:prettier/recommended',
],
extends: ['eslint:recommended', 'plugin:node/recommended', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 2022,
},
ignorePatterns: [
'.eslintrc.js',
'.prettierrc',
],
ignorePatterns: ['.eslintrc.js', '.prettierrc'],
plugins: ['no-only-tests'],
rules: {
'no-const-assign': 'error',
Expand Down
Loading

0 comments on commit d7e3d74

Please sign in to comment.