Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ __pycache__
*.pyc
dist/
py/selenium/webdriver/common/bidi/
# Generated internal BiDi protocol modules; the hand-written runtime beside them stays tracked.
py/selenium/webdriver/common/_bidi/*
!py/selenium/webdriver/common/_bidi/__init__.py
!py/selenium/webdriver/common/_bidi/serialization.py
!py/selenium/webdriver/common/_bidi/transport.py
!py/selenium/webdriver/common/_bidi/domain.py
py/selenium/webdriver/common/devtools/**/*
!py/selenium/webdriver/common/devtools/util.py
py/selenium/webdriver/common/linux/
Expand Down
57 changes: 55 additions & 2 deletions py/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ load("//common:defs.bzl", "copy_file")
load("//py:defs.bzl", "generate_devtools", "generate_devtools_latest", "py_test_suite")
load("//py/private:browsers.bzl", "BROWSERS")
load("//py/private:generate_bidi.bzl", "generate_bidi")
load("//py/private:generate_bidi_protocol.bzl", "generate_bidi_protocol")
load("//py/private:import.bzl", "py_import")
load("//py/private:sphinx_docs.bzl", "sphinx_docs")

Expand Down Expand Up @@ -310,6 +311,7 @@ py_library(
"selenium/webdriver/common/actions/**",
"selenium/webdriver/common/alert.py",
"selenium/webdriver/common/api_request_context.py",
"selenium/webdriver/common/_bidi/**",
"selenium/webdriver/common/bidi/**",
"selenium/webdriver/common/devtools/**",
"selenium/webdriver/common/fedcm/**",
Expand Down Expand Up @@ -546,6 +548,7 @@ py_library(
visibility = ["//visibility:public"],
deps = [
":bidi",
":bidi_protocol",
":chrome",
":chromium",
":common",
Expand Down Expand Up @@ -578,6 +581,7 @@ py_package(
"py.selenium.webdriver.chrome",
"py.selenium.webdriver.chromium",
"py.selenium.webdriver.common",
"py.selenium.webdriver.common._bidi",
"py.selenium.webdriver.common.bidi",
"py.selenium.webdriver.common.devtools",
"py.selenium.webdriver.common.devtools.latest",
Expand Down Expand Up @@ -772,6 +776,51 @@ generate_bidi(
spec_version = "1.0",
)

# Schema-driven internal BiDi protocol layer: generated at build time from the
# shared BiDi schema into `selenium/webdriver/common/_bidi/`. Only the hand-written
# runtime (serialization/transport/domain) is checked in; the domain modules are
# generated by the rule below and never committed.
generate_bidi_protocol(
name = "create-bidi-protocol-src",
generator = ":generate-bidi-protocol-tool",
package = "selenium/webdriver/common/_bidi",
schema = "//javascript/selenium-webdriver:create-bidi-src_schema",
)

# Build-graph tool: the generator invoked by the rule above (schema + output dir
# passed as arguments). No baked args, so it is reusable in the exec configuration.
py_binary(
name = "generate-bidi-protocol-tool",
srcs = ["generate_bidi_protocol.py"],
main = "generate_bidi_protocol.py",
visibility = ["//visibility:private"],
)

# `bazel run //py:generate-bidi-protocol` regenerates the checked-out tree for local
# development (writes under BUILD_WORKSPACE_DIRECTORY); the build itself uses the rule.
py_binary(
name = "generate-bidi-protocol",
srcs = ["generate_bidi_protocol.py"],
args = ["$(location //javascript/selenium-webdriver:create-bidi-src_schema)"],
data = ["//javascript/selenium-webdriver:create-bidi-src_schema"],
main = "generate_bidi_protocol.py",
visibility = ["//visibility:public"],
)

py_library(
name = "bidi_protocol",
# Listed explicitly, not globbed: a local generate run drops the generated modules here too, and a glob would double them against the rule's outputs.
srcs = [":create-bidi-protocol-src"] + [
"selenium/webdriver/common/_bidi/__init__.py",
"selenium/webdriver/common/_bidi/domain.py",
"selenium/webdriver/common/_bidi/serialization.py",
"selenium/webdriver/common/_bidi/transport.py",
],
imports = ["."],
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
visibility = ["//visibility:public"],
deps = [":exceptions"],
)

py_test_suite(
name = "unit",
size = "small",
Expand Down Expand Up @@ -800,7 +849,10 @@ py_library(
deps = [],
)

BIDI_TESTS = glob(["test/selenium/webdriver/common/**/*bidi*_tests.py"])
BIDI_TESTS = glob([
"test/selenium/webdriver/common/bidi/**/*_tests.py",
"test/selenium/webdriver/common/_bidi/**/*_tests.py",
])

# Tests that have bidi and classic implementations.
BIDI_IMPLEMENTATIONS = []
Expand Down Expand Up @@ -1056,7 +1108,8 @@ FEATURE_SUITE_DEFS = {
target_compatible_with = BROWSERS[browser]["target_compatible_with"],
test_suffix = "%s-bidi" % browser,
deps = [
":common_alert", # bidi_browsing_context_tests.py calls EC.alert_is_present()
":bidi_protocol", # bidi/protocol_tests.py imports the generated _bidi layer directly
":common_alert", # bidi/browsing_context_tests.py calls EC.alert_is_present()
":init-tree",
":webserver",
] + BROWSER_TESTS[browser]["deps"] + TEST_DEPS,
Expand Down
2 changes: 1 addition & 1 deletion py/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bazel test //py/... --test_output=streamed # Live output for debugging
bazel test //py:test-chrome --headless

# Run a specific test in a test file
bazel test //py:test/selenium/webdriver/common/bidi_browsing_context_tests-chrome-bidi \
bazel test //py:test/selenium/webdriver/common/bidi/browsing_context_tests-chrome-bidi \
--test_arg=-k \
--test_arg=test_get_tree_with_child \

Expand Down
Loading
Loading