Skip to content

Commit

Permalink
Merge branch 'trunk' into add_javadoc_support_event_classes
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner authored Nov 27, 2023
2 parents 803265b + c806757 commit 563d81b
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
java-version: ${{ inputs.java-version }}
distribution: 'temurin'
- name: Setup Bazel
uses: p0deje/setup-bazel@0.2.0
uses: p0deje/setup-bazel@0.3.2
with:
bazelisk-cache: true
disk-cache: ${{ inputs.cache-key }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
fetch-depth: 50
- name: Setup Bazel
uses: p0deje/setup-bazel@0.2.0
uses: p0deje/setup-bazel@0.3.2
with:
bazelisk-cache: true
external-cache: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/should-workflow-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
fetch-depth: 50
- name: Setup Bazel
uses: p0deje/setup-bazel@0.2.0
uses: p0deje/setup-bazel@0.3.2
with:
bazelisk-cache: true
external-cache: |
Expand Down
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ pin_browsers()

http_archive(
name = "rules_ruby",
sha256 = "34296f8cad46ec10b7eea59f3399feabcfbc33935b7d8bec880ea0ecfadc23b5",
strip_prefix = "rules_ruby-9550503e1c1702375e87837d43eb137030edd28a",
url = "https://github.com/p0deje/rules_ruby/archive/9550503e1c1702375e87837d43eb137030edd28a.zip",
sha256 = "92055f29f94963cd3cf7be1da15503c3306879e2e8545b2b5f9e5bb37d6713d3",
strip_prefix = "rules_ruby-0.2.0",
url = "https://github.com/p0deje/rules_ruby/releases/download/v0.2.0/rules_ruby-v0.2.0.tar.gz",
)

load(
Expand Down
12 changes: 12 additions & 0 deletions java/src/org/openqa/selenium/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,18 @@ public String toString() {
}
},

SONOMA("sonoma", "os x 14.0", "macos 14.0") {
@Override
public Platform family() {
return MAC;
}

@Override
public String toString() {
return "macOS 14.0";
}
},

/** Many platforms have UNIX traits, amongst them LINUX, Solaris and BSD. */
UNIX("solaris", "bsd") {
@Override
Expand Down
14 changes: 13 additions & 1 deletion java/src/org/openqa/selenium/manager/SeleniumManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
// under the License.
package org.openqa.selenium.manager;

import static org.openqa.selenium.Platform.LINUX;
import static org.openqa.selenium.Platform.MAC;
import static org.openqa.selenium.Platform.UNIX;
import static org.openqa.selenium.Platform.WINDOWS;

import java.io.IOException;
Expand Down Expand Up @@ -171,13 +173,23 @@ private synchronized Path getBinary() {
if (binary == null) {
try {
Platform current = Platform.getCurrent();
String folder = "linux";
String folder = "";
String extension = "";
if (current.is(WINDOWS)) {
extension = EXE;
folder = "windows";
} else if (current.is(MAC)) {
folder = "macos";
} else if (current.is(LINUX)) {
folder = "linux";
} else if (current.is(UNIX)) {
LOG.warning(
String.format(
"Selenium Manager binary may not be compatible with %s; verify settings",
current));
folder = "linux";
} else {
throw new WebDriverException("Unsupported platform: " + current);
}

binary = getBinaryInCache(SELENIUM_MANAGER + extension);
Expand Down
5 changes: 5 additions & 0 deletions py/selenium/webdriver/common/bidi/cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ async def _reader_task(self):
else:
self._handle_data(data)

for _, session in self.sessions.items():
for _, senders in session.channels.items():
for sender in senders:
sender.close()


@asynccontextmanager
async def open_cdp(url) -> typing.AsyncIterator[CdpConnection]:
Expand Down
29 changes: 19 additions & 10 deletions py/selenium/webdriver/common/selenium_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,32 @@ def get_binary() -> Path:
"""Determines the path of the correct Selenium Manager binary.
:Returns: The Selenium Manager executable location
:Raises: WebDriverException if the platform is unsupported
"""

if (path := os.getenv("SE_MANAGER_PATH")) is not None:
return Path(path)
else:
platform = sys.platform

dirs = {
"darwin": "macos",
"win32": "windows",
"cygwin": "windows",
}
dirs = {
"darwin": "macos",
"win32": "windows",
"cygwin": "windows",
"linux": "linux",
"freebsd": "linux",
"openbsd": "linux",
}

directory = dirs.get(sys.platform)
if directory is None:
raise WebDriverException(f"Unsupported platform: {sys.platform}")

if sys.platform in ["freebsd", "openbsd"]:
logger.warning("Selenium Manager binary may not be compatible with %s; verify settings", sys.platform)

directory = dirs.get(platform) if dirs.get(platform) else platform
file = "selenium-manager.exe" if directory == "windows" else "selenium-manager"
file = "selenium-manager.exe" if directory == "windows" else "selenium-manager"

path = Path(__file__).parent.joinpath(directory, file)
path = Path(__file__).parent.joinpath(directory, file)

if not path.is_file():
raise WebDriverException(f"Unable to obtain working Selenium Manager binary; {path}")
Expand Down
3 changes: 2 additions & 1 deletion py/selenium/webdriver/remote/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from base64 import encodebytes
from hashlib import md5 as md5_hash
from io import BytesIO
from typing import List

from selenium.common.exceptions import JavascriptException
from selenium.common.exceptions import WebDriverException
Expand Down Expand Up @@ -415,7 +416,7 @@ def find_element(self, by=By.ID, value=None) -> WebElement:

return self._execute(Command.FIND_CHILD_ELEMENT, {"using": by, "value": value})["value"]

def find_elements(self, by=By.ID, value=None) -> list[WebElement]:
def find_elements(self, by=By.ID, value=None) -> List[WebElement]:
"""Find elements given a By strategy and locator.
:Usage:
Expand Down
4 changes: 4 additions & 0 deletions rb/lib/selenium/webdriver/common/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def linux?
os == :linux
end

def unix?
os == :unix
end

def wsl?
return false unless linux?

Expand Down
10 changes: 8 additions & 2 deletions rb/lib/selenium/webdriver/common/selenium_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def driver_path(options)

output = run(*command)

browser_path = output['browser_path']
driver_path = output['driver_path']
browser_path = Platform.cygwin? ? Platform.cygwin_path(output['browser_path']) : output['browser_path']
driver_path = Platform.cygwin? ? Platform.cygwin_path(output['driver_path']) : output['driver_path']
Platform.assert_executable driver_path

if options.respond_to?(:binary) && browser_path && !browser_path.empty?
Expand Down Expand Up @@ -83,7 +83,13 @@ def binary
"#{directory}/macos/selenium-manager"
elsif Platform.linux?
"#{directory}/linux/selenium-manager"
elsif Platform.unix?
WebDriver.logger.warn('Selenium Manager binary may not be compatible with Unix; verify settings',
id: %i[selenium_manager unix_binary])
"#{directory}/linux/selenium-manager"
end
rescue Error::WebDriverError => e
raise Error::WebDriverError, "Unable to obtain Selenium Manager binary for #{e.message}"
end)

validate_location(location)
Expand Down
4 changes: 2 additions & 2 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ pub trait SeleniumManager {
} else {
self.set_browser_version(discovered_version);
}
if self.is_webview2() {
if self.is_webview2() && PathBuf::from(self.get_browser_path()).is_dir() {
let browser_path = format!(
r#"{}\{}\msedge{}"#,
self.get_browser_path(),
Expand Down Expand Up @@ -1029,7 +1029,7 @@ pub trait SeleniumManager {
let mut commands = Vec::new();

if WINDOWS.is(self.get_os()) {
if !escaped_browser_path.is_empty() && !self.is_webview2() {
if !escaped_browser_path.is_empty() {
let wmic_command =
Command::new_single(format_one_arg(WMIC_COMMAND, &escaped_browser_path));
commands.push(wmic_command);
Expand Down
4 changes: 3 additions & 1 deletion rust/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use Color::{Blue, Cyan, Green, Red, Yellow};
pub const DRIVER_PATH: &str = "Driver path: ";
pub const BROWSER_PATH: &str = "Browser path: ";

#[derive(Default)]
#[derive(Default, PartialEq)]
enum OutputType {
#[default]
Logger,
Expand Down Expand Up @@ -219,6 +219,8 @@ impl Logger {
let json = json_output.deref();
if !json.logs.is_empty() {
print!("{}", serde_json::to_string_pretty(json).unwrap());
} else if self.output == OutputType::Json {
panic!("JSON output has been specified, but no entries have been collected")
}
}
}

0 comments on commit 563d81b

Please sign in to comment.