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
AdamPDotty authored Sep 19, 2024
2 parents 2e2837b + 747c6bf commit 1434d9e
Show file tree
Hide file tree
Showing 34 changed files with 379 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ jobs:
with:
ruby-version: '3.1'
working-directory: 'rb'
- name: Setup curl for Ubuntu
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
- name: "Prep git"
run: |
git config --local user.email "selenium-ci@users.noreply.github.com"
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/stage-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release Staging

on:
pull_request:
types: [closed]
types: [ closed ]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -42,16 +42,18 @@ jobs:
with:
java-version: 17
distribution: 'temurin'
- name: Setup curl for Ubuntu
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
- name: Build and Stage Packages
run: ./go all:package[--config=release]
- name: Generate Draft Release
uses: softprops/action-gh-release@v2
with:
name: Selenium ${{ env.VERSION }}
body: |
## Detailed Changelogs by Component
<img src="https://www.selenium.dev/images/programming/java.svg" width="20" height="20"> **[Java](https://github.com/SeleniumHQ/selenium/blob/trunk/java/CHANGELOG)** &nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<img src="https://www.selenium.dev/images/programming/python.svg" width="20" height="20"> **[Python](https://github.com/SeleniumHQ/selenium/blob/trunk/py/CHANGES)** &nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<img src="https://www.selenium.dev/images/programming/csharp.svg" width="20" height="20"> **[DotNet](https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/CHANGELOG)** &nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<img src="https://www.selenium.dev/images/programming/ruby.svg" width="20" height="20"> **[Ruby](https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES)** &nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<img src="https://www.selenium.dev/images/programming/javascript.svg" width="20" height="20"> **[JavaScript](https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/node/selenium-webdriver/CHANGES.md)** &nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<img src="https://www.selenium.dev/images/browsers/internet-explorer.svg" width="20" height="20"> **[IEDriver](https://github.com/SeleniumHQ/selenium/blob/trunk/cpp/iedriverserver/CHANGELOG)**
<br>
## Detailed Changelogs by Component
<img src="https://www.selenium.dev/images/programming/java.svg" width="20" height="20"> **[Java](https://github.com/SeleniumHQ/selenium/blob/trunk/java/CHANGELOG)** &nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<img src="https://www.selenium.dev/images/programming/python.svg" width="20" height="20"> **[Python](https://github.com/SeleniumHQ/selenium/blob/trunk/py/CHANGES)** &nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<img src="https://www.selenium.dev/images/programming/csharp.svg" width="20" height="20"> **[DotNet](https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/CHANGELOG)** &nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<img src="https://www.selenium.dev/images/programming/ruby.svg" width="20" height="20"> **[Ruby](https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES)** &nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<img src="https://www.selenium.dev/images/programming/javascript.svg" width="20" height="20"> **[JavaScript](https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/node/selenium-webdriver/CHANGES.md)** &nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<img src="https://www.selenium.dev/images/browsers/internet-explorer.svg" width="20" height="20"> **[IEDriver](https://github.com/SeleniumHQ/selenium/blob/trunk/cpp/iedriverserver/CHANGELOG)**
<br>
tag_name: selenium-${{ env.VERSION }}
draft: true
generate_release_notes: true
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ py/docs/source/**/*
py/build/
py/LICENSE
py/pytestdebug.log
py/python.iml
selenium.egg-info/
third_party/java/jetty/jetty-repacked.jar
*.user
Expand Down Expand Up @@ -140,3 +141,4 @@ javascript/node/selenium-webdriver/.vscode/settings.json

dotnet-bin
.metadata/
.npmrc
10 changes: 5 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module(name = "selenium")

bazel_dep(name = "apple_rules_lint", version = "0.4.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.7.9")
bazel_dep(name = "aspect_rules_esbuild", version = "0.20.1")
bazel_dep(name = "aspect_rules_js", version = "1.42.3")
bazel_dep(name = "aspect_rules_ts", version = "2.4.2")
bazel_dep(name = "aspect_bazel_lib", version = "2.8.1")
bazel_dep(name = "aspect_rules_esbuild", version = "0.21.0")
bazel_dep(name = "aspect_rules_js", version = "2.0.1")
bazel_dep(name = "aspect_rules_ts", version = "3.1.0")
bazel_dep(name = "bazel_features", version = "1.13.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0")
Expand All @@ -18,7 +18,7 @@ bazel_dep(name = "protobuf", version = "21.7", dev_dependency = True, repo_name
bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)

bazel_dep(name = "rules_dotnet", version = "0.15.1")
bazel_dep(name = "rules_java", version = "7.6.3")
bazel_dep(name = "rules_java", version = "7.11.1")
bazel_dep(name = "rules_jvm_external", version = "6.3")
bazel_dep(name = "rules_nodejs", version = "6.2.0")
bazel_dep(name = "rules_oci", version = "1.7.6")
Expand Down
6 changes: 3 additions & 3 deletions dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OpenQA.Selenium.BiDi;

public static class WebDriverExtensions
{
public static async Task<BiDi> AsBidirectionalAsync(this IWebDriver webDriver)
public static async Task<BiDi> AsBiDiAsync(this IWebDriver webDriver)
{
var webSocketUrl = ((IHasCapabilities)webDriver).Capabilities.GetCapability("webSocketUrl");

Expand All @@ -16,9 +16,9 @@ public static async Task<BiDi> AsBidirectionalAsync(this IWebDriver webDriver)
return bidi;
}

public static async Task<BrowsingContext> AsBidirectionalContextAsync(this IWebDriver webDriver)
public static async Task<BrowsingContext> AsBiDiContextAsync(this IWebDriver webDriver)
{
var bidi = await webDriver.AsBidirectionalAsync();
var bidi = await webDriver.AsBiDiAsync();

var currentBrowsingContext = new BrowsingContext(bidi, webDriver.CurrentWindowHandle);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ private Collection<Cookie> getCookies(HttpRequest request) {
private void addCookie(HttpResponse response, Cookie cook) {
StringBuilder cookie = new StringBuilder();

// TODO: escape string as necessary
String name = cook.getName();
cookie.append(name).append("=").append(cook.getValue()).append("; ");
String name = escapeCookieValue(cook.getName());
String value = escapeCookieValue(cook.getValue());
cookie.append(name).append("=").append(value).append("; ");

append(cookie, cook.getDomain(), str -> "Domain=" + str);
append(cookie, cook.getPath(), str -> "Path=" + str);
Expand Down Expand Up @@ -191,4 +191,45 @@ private Cookie parse(String cookieString) {

return builder.build();
}

private String escapeCookieValue(String value) {
if (value == null || value.isEmpty()) {
return "";
}

StringBuilder cookieValue = new StringBuilder();

for (char c : value.toCharArray()) {
switch (c) {
case '\\':
cookieValue.append("\\\\");
break;
case '"':
cookieValue.append("\\\"");
break;
case ';':
cookieValue.append("\\;");
break;
case ',':
cookieValue.append("\\,");
break;
case '\r':
case '\n':
// Skip carriage return and newline characters
break;
case '<':
cookieValue.append("&lt;");
break;
case '>':
cookieValue.append("&gt;");
break;
case '&':
cookieValue.append("&amp;");
break;
default:
cookieValue.append(c); // Append safe characters as they are
}
}
return cookieValue.toString();
}
}
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 4.24.1

- Close CDP websocket connection on driver.quit (#14501)
- Close CDP websocket connection on driver.quit (#14501)

## 4.24.0

Expand Down
4 changes: 3 additions & 1 deletion javascript/node/selenium-webdriver/test/bidi/network_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ suite(
it('can listen to event before request is sent', async function () {
let beforeRequestEvent = null
await network.beforeRequestSent(function (event) {
beforeRequestEvent = event
if (event.request.url.includes('empty')) {
beforeRequestEvent = event
}
})

await driver.get(Pages.emptyPage)
Expand Down
29 changes: 14 additions & 15 deletions py/test/selenium/webdriver/common/correct_event_firing_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,20 @@ def test_clearing_an_element_should_cause_the_on_change_handler_to_fire(driver,
assert result.text == "Cleared"


# TODO Currently Failing and needs fixing
# def test_sending_keys_to_another_element_should_cause_the_blur_event_to_fire(driver, pages):
# pages.load("javascriptPage.html")
# element = driver.find_element(By.ID, "theworks")
# element.send_keys("foo")
# element2 = driver.find_element(By.ID, "changeable")
# element2.send_keys("bar")
# _assertEventFired(driver, "blur")

# TODO Currently Failing and needs fixing
# def test_sending_keys_to_an_element_should_cause_the_focus_event_to_fire(driver, pages):
# pages.load("javascriptPage.html")
# element = driver.find_element(By.ID, "theworks")
# element.send_keys("foo")
# _assertEventFired(driver, "focus")
def test_sending_keys_to_another_element_should_cause_the_blur_event_to_fire(driver, pages):
pages.load("javascriptPage.html")
element = driver.find_element(By.ID, "theworks")
element.send_keys("foo")
element2 = driver.find_element(By.ID, "changeable")
element2.send_keys("bar")
_assert_event_fired(driver, "blur")


def test_sending_keys_to_an_element_should_cause_the_focus_event_to_fire(driver, pages):
pages.load("javascriptPage.html")
element = driver.find_element(By.ID, "theworks")
element.send_keys("foo")
_assert_event_fired(driver, "focus")


def _click_on_element_which_records_events(driver):
Expand Down
1 change: 1 addition & 0 deletions rb/lib/selenium/webdriver/chrome/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Service < WebDriver::Service
DEFAULT_PORT = 9515
EXECUTABLE = 'chromedriver'
SHUTDOWN_SUPPORTED = true
DRIVER_PATH_ENV_KEY = 'SE_CHROMEDRIVER'

def log
return @log unless @log.is_a? String
Expand Down
15 changes: 11 additions & 4 deletions rb/lib/selenium/webdriver/common/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def driver_path=(path)
def initialize(path: nil, port: nil, log: nil, args: nil)
port ||= self.class::DEFAULT_PORT
args ||= []
path ||= env_path

@executable_path = path
@host = Platform.localhost
Expand All @@ -87,16 +88,22 @@ def initialize(path: nil, port: nil, log: nil, args: nil)
end

def launch
@executable_path ||= begin
default_options = WebDriver.const_get("#{self.class.name&.split('::')&.[](2)}::Options").new
DriverFinder.new(default_options, self).driver_path
end
@executable_path ||= env_path || find_driver_path
ServiceManager.new(self).tap(&:start)
end

def shutdown_supported
self.class::SHUTDOWN_SUPPORTED
end

def find_driver_path
default_options = WebDriver.const_get("#{self.class.name&.split('::')&.[](2)}::Options").new
DriverFinder.new(default_options, self).driver_path
end

def env_path
ENV.fetch(self.class::DRIVER_PATH_ENV_KEY, nil)
end
end # Service
end # WebDriver
end # Selenium
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/edge/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Service < WebDriver::Service
DEFAULT_PORT = 9515
EXECUTABLE = 'msedgedriver'
SHUTDOWN_SUPPORTED = true

DRIVER_PATH_ENV_KEY = 'SE_EDGEDRIVER'
def log
return @log unless @log.is_a? String

Expand Down
1 change: 1 addition & 0 deletions rb/lib/selenium/webdriver/firefox/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Service < WebDriver::Service
DEFAULT_PORT = 4444
EXECUTABLE = 'geckodriver'
SHUTDOWN_SUPPORTED = false
DRIVER_PATH_ENV_KEY = 'SE_GECKODRIVER'
end # Service
end # Firefox
end # WebDriver
Expand Down
1 change: 1 addition & 0 deletions rb/lib/selenium/webdriver/ie/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Service < WebDriver::Service
DEFAULT_PORT = 5555
EXECUTABLE = 'IEDriverServer'
SHUTDOWN_SUPPORTED = true
DRIVER_PATH_ENV_KEY = 'SE_IEDRIVER'
end # Server
end # IE
end # WebDriver
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/safari/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Service < WebDriver::Service
DEFAULT_PORT = 7050
EXECUTABLE = 'safaridriver'
SHUTDOWN_SUPPORTED = false

DRIVER_PATH_ENV_KEY = 'SE_SAFARIDRIVER'
def initialize(path: nil, port: nil, log: nil, args: nil)
raise Error::WebDriverError, 'Safari Service does not support setting log output' if log

Expand Down
2 changes: 2 additions & 0 deletions rb/sig/lib/selenium/webdriver/chrome/service.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Selenium
module WebDriver
module Chrome
class Service < WebDriver::Service
DRIVER_PATH_ENV_KEY: String

@log: untyped

DEFAULT_PORT: Integer
Expand Down
2 changes: 2 additions & 0 deletions rb/sig/lib/selenium/webdriver/common/service.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ module Selenium

attr_accessor args: untyped

def env_path: -> String

alias extra_args args

def initialize: (?path: untyped?, ?port: untyped?, ?log: untyped?, ?args: untyped?) -> void
Expand Down
2 changes: 2 additions & 0 deletions rb/sig/lib/selenium/webdriver/edge/service.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Selenium
module WebDriver
module Edge
class Service < WebDriver::Service
DRIVER_PATH_ENV_KEY: String

@log: untyped

DEFAULT_PORT: Integer
Expand Down
1 change: 1 addition & 0 deletions rb/sig/lib/selenium/webdriver/firefox/service.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Selenium
class Service < WebDriver::Service
DEFAULT_PORT: 4444

DRIVER_PATH_ENV_KEY: String
EXECUTABLE: "geckodriver"

SHUTDOWN_SUPPORTED: false
Expand Down
1 change: 1 addition & 0 deletions rb/sig/lib/selenium/webdriver/ie/service.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Selenium
class Service < WebDriver::Service
DEFAULT_PORT: Integer

DRIVER_PATH_ENV_KEY: String
EXECUTABLE: String

SHUTDOWN_SUPPORTED: bool
Expand Down
1 change: 1 addition & 0 deletions rb/sig/lib/selenium/webdriver/safari/service.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Selenium
class Service < WebDriver::Service
DEFAULT_PORT: Integer

DRIVER_PATH_ENV_KEY: String
EXECUTABLE: String

SHUTDOWN_SUPPORTED: bool
Expand Down
43 changes: 43 additions & 0 deletions rb/spec/integration/selenium/webdriver/ie/service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# frozen_string_literal: true

# 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.

require_relative '../spec_helper'

module Selenium
module WebDriver
module IE
describe Service, exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: :ie}] do
let(:service) { described_class.new }
let(:service_manager) { service.launch }

after { service_manager.stop }

it 'auto uses iedriver' do
service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path

expect(service_manager.uri).to be_a(URI)
end

it 'can be started outside driver' do
expect(service_manager.uri).to be_a(URI)
end
end
end # IE
end # WebDriver
end # Selenium
Loading

0 comments on commit 1434d9e

Please sign in to comment.