Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2e838e5
[py] Add type stubs for selenium.webdriver and stub generator script
cgoldberg Mar 3, 2026
26f9b4f
Merge branch 'trunk' into py-type-stubs
cgoldberg Mar 3, 2026
15e572c
Add to BUILD.bazel
cgoldberg Mar 3, 2026
48e3cfe
Refactored approach using forward references
cgoldberg Mar 3, 2026
e114305
Add ruff noqa
cgoldberg Mar 3, 2026
c6e4b4a
Fix quotes
cgoldberg Mar 3, 2026
f6a332e
Fix heading
cgoldberg Mar 3, 2026
48ede22
Fix script spacing
cgoldberg Mar 3, 2026
0c82afb
Fix bazel
cgoldberg Mar 3, 2026
ee62049
Fix bazel
cgoldberg Mar 3, 2026
a43d994
Fix generator
cgoldberg Mar 3, 2026
3c36ced
Fix generator
cgoldberg Mar 3, 2026
ce5cc92
Use new pyi
cgoldberg Mar 3, 2026
1db212c
Remove generator and just use a static file
cgoldberg Mar 3, 2026
6772c14
Fix
cgoldberg Mar 3, 2026
c248c49
Include type stubs in pyproject.toml for building from sdist
cgoldberg Mar 3, 2026
f0f0ee2
Remove forward references
cgoldberg Mar 3, 2026
67d8961
Add submodules
cgoldberg Mar 3, 2026
730a11c
Fix formatting
cgoldberg Mar 3, 2026
a9e20e1
Fix imports
cgoldberg Mar 3, 2026
4dab62e
Fix imports
cgoldberg Mar 3, 2026
c95eb0b
Add __all__ for wildcard imports
cgoldberg Mar 3, 2026
01c4482
Remove unused import
cgoldberg Mar 3, 2026
2a19cf7
Merge branch 'trunk' into py-type-stubs
cgoldberg Mar 3, 2026
b996af5
Merge branch 'trunk' into py-type-stubs
cgoldberg Mar 3, 2026
be3ffc3
Merge branch 'SeleniumHQ:trunk' into py-type-stubs
cgoldberg Mar 4, 2026
dce891a
Merge branch 'trunk' into py-type-stubs
cgoldberg Mar 5, 2026
9352923
Merge branch 'trunk' into py-type-stubs
cgoldberg Mar 5, 2026
bcdcd16
Merge branch 'trunk' into py-type-stubs
cgoldberg Mar 5, 2026
25187f5
Add the rest of the missing type stubs
cgoldberg Mar 5, 2026
08082e3
Consolidate imports
cgoldberg Mar 5, 2026
d17a05a
Add to bazel and remove redundant aliases
cgoldberg Mar 5, 2026
028beaa
Use relative names for modules and add to exposed names
cgoldberg Mar 5, 2026
c047989
Merge branch 'SeleniumHQ:trunk' into py-type-stubs
cgoldberg Mar 5, 2026
406716c
Fix formatting
cgoldberg Mar 5, 2026
b2c067f
Merge branch 'trunk' into py-type-stubs
cgoldberg Mar 6, 2026
9549484
Merge branch 'trunk' into py-type-stubs
cgoldberg Mar 8, 2026
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
16 changes: 12 additions & 4 deletions py/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ py_library(
"selenium/__init__.py",
"selenium/webdriver/__init__.py",
] + glob(["selenium/common/**/*.py"]),
data = ["selenium/webdriver/__init__.pyi"],
imports = ["."],
visibility = ["//visibility:public"],
)
Expand Down Expand Up @@ -277,9 +278,7 @@ py_library(
name = "common",
srcs = glob(
["selenium/webdriver/common/**/*.py"],
exclude = [
"selenium/webdriver/common/bidi/**",
],
exclude = ["selenium/webdriver/common/bidi/**"],
),
data = [
":manager-linux",
Expand Down Expand Up @@ -325,6 +324,7 @@ py_library(
py_library(
name = "chrome",
srcs = glob(["selenium/webdriver/chrome/**/*.py"]),
data = ["selenium/webdriver/chrome/__init__.pyi"],
imports = ["."],
visibility = ["//visibility:public"],
deps = [":chromium"],
Expand All @@ -334,6 +334,7 @@ py_library(
py_library(
name = "edge",
srcs = glob(["selenium/webdriver/edge/**/*.py"]),
data = ["selenium/webdriver/edge/__init__.pyi"],
imports = ["."],
visibility = ["//visibility:public"],
deps = [":chromium"],
Expand All @@ -343,7 +344,10 @@ py_library(
py_library(
name = "firefox",
srcs = glob(["selenium/webdriver/firefox/**/*.py"]),
data = [":firefox-driver-prefs"],
data = [
"selenium/webdriver/firefox/__init__.pyi",
":firefox-driver-prefs",
],
imports = ["."],
visibility = ["//visibility:public"],
deps = [
Expand All @@ -356,6 +360,7 @@ py_library(
py_library(
name = "safari",
srcs = glob(["selenium/webdriver/safari/**/*.py"]),
data = ["selenium/webdriver/safari/__init__.pyi"],
imports = ["."],
visibility = ["//visibility:public"],
deps = [
Expand All @@ -368,6 +373,7 @@ py_library(
py_library(
name = "ie",
srcs = glob(["selenium/webdriver/ie/**/*.py"]),
data = ["selenium/webdriver/ie/__init__.pyi"],
imports = ["."],
visibility = ["//visibility:public"],
deps = [
Expand All @@ -380,6 +386,7 @@ py_library(
py_library(
name = "webkitgtk",
srcs = glob(["selenium/webdriver/webkitgtk/**/*.py"]),
data = ["selenium/webdriver/webkitgtk/__init__.pyi"],
imports = ["."],
visibility = ["//visibility:public"],
deps = [
Expand All @@ -392,6 +399,7 @@ py_library(
py_library(
name = "wpewebkit",
srcs = glob(["selenium/webdriver/wpewebkit/**/*.py"]),
data = ["selenium/webdriver/wpewebkit/__init__.pyi"],
imports = ["."],
visibility = ["//visibility:public"],
deps = [
Expand Down
1 change: 1 addition & 0 deletions py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ binding = "Exec"
[tool.setuptools.package-data]
"*" = [
"*.py",
"*.pyi",
"*.rst",
"*.json",
"*.xpi",
Expand Down
131 changes: 131 additions & 0 deletions py/selenium/webdriver/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# 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.
#
# 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.

"""Type stub with lazy import mapping from __init__.py.

This stub file is necessary for type checkers and IDEs to automatically have
visibility into lazy modules since they are not imported immediately at runtime.
"""

# ruff: noqa: I001

# Expose runtime version
__version__: str

# Chrome
from selenium.webdriver.chrome.webdriver import WebDriver as Chrome
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.chrome.service import Service as ChromeService

# Edge
from selenium.webdriver.edge.webdriver import WebDriver as Edge
from selenium.webdriver.edge.webdriver import WebDriver as ChromiumEdge
from selenium.webdriver.edge.options import Options as EdgeOptions
from selenium.webdriver.edge.service import Service as EdgeService

# Firefox
from selenium.webdriver.firefox.webdriver import WebDriver as Firefox
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile

# IE
from selenium.webdriver.ie.webdriver import WebDriver as Ie
from selenium.webdriver.ie.options import Options as IeOptions
from selenium.webdriver.ie.service import Service as IeService

# Safari
from selenium.webdriver.safari.webdriver import WebDriver as Safari
from selenium.webdriver.safari.options import Options as SafariOptions
from selenium.webdriver.safari.service import Service as SafariService

# Remote
from selenium.webdriver.remote.webdriver import WebDriver as Remote

# WebKitGTK
from selenium.webdriver.webkitgtk.webdriver import WebDriver as WebKitGTK
from selenium.webdriver.webkitgtk.options import Options as WebKitGTKOptions
from selenium.webdriver.webkitgtk.service import Service as WebKitGTKService

# WPEWebKit
from selenium.webdriver.wpewebkit.webdriver import WebDriver as WPEWebKit
from selenium.webdriver.wpewebkit.options import Options as WPEWebKitOptions
from selenium.webdriver.wpewebkit.service import Service as WPEWebKitService

# Common utilities
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.proxy import Proxy

# Submodules
from . import chrome
from . import chromium
from . import common
from . import edge
from . import firefox
from . import ie
from . import remote
from . import safari
from . import support
from . import webkitgtk
from . import wpewebkit

# Exposed names
__all__ = [
# Classes
"ActionChains",
"Chrome",
"ChromeOptions",
"ChromeService",
"ChromiumEdge",
"DesiredCapabilities",
"Edge",
"EdgeOptions",
"EdgeService",
"Firefox",
"FirefoxOptions",
"FirefoxProfile",
"FirefoxService",
"Ie",
"IeOptions",
"IeService",
"Keys",
"Proxy",
"Remote",
"Safari",
"SafariOptions",
"SafariService",
"WPEWebKit",
"WPEWebKitOptions",
"WPEWebKitService",
"WebKitGTK",
"WebKitGTKOptions",
"WebKitGTKService",
# Submodules
"chrome",
"chromium",
"common",
"edge",
"firefox",
"ie",
"remote",
"safari",
"support",
"webkitgtk",
"wpewebkit",
]
26 changes: 26 additions & 0 deletions py/selenium/webdriver/chrome/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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.
#
# 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.

"""Type stub with lazy import mapping from __init__.py.

This stub file is necessary for type checkers and IDEs to automatically have
visibility into lazy modules since they are not imported immediately at runtime.
"""

from . import options, remote_connection, service, webdriver

__all__ = ["options", "remote_connection", "service", "webdriver"]
2 changes: 1 addition & 1 deletion py/selenium/webdriver/chrome/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# under the License.


from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.remote.client_config import ClientConfig


Expand Down
26 changes: 26 additions & 0 deletions py/selenium/webdriver/edge/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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.
#
# 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.

"""Type stub with lazy import mapping from __init__.py.

This stub file is necessary for type checkers and IDEs to automatically have
visibility into lazy modules since they are not imported immediately at runtime.
"""

from . import options, remote_connection, service, webdriver

__all__ = ["options", "remote_connection", "service", "webdriver"]
2 changes: 1 addition & 1 deletion py/selenium/webdriver/edge/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# under the License.


from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.remote.client_config import ClientConfig


Expand Down
26 changes: 26 additions & 0 deletions py/selenium/webdriver/firefox/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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.
#
# 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.

"""Type stub with lazy import mapping from __init__.py.

This stub file is necessary for type checkers and IDEs to automatically have
visibility into lazy modules since they are not imported immediately at runtime.
"""

from . import firefox_profile, options, remote_connection, service, webdriver

__all__ = ["firefox_profile", "options", "remote_connection", "service", "webdriver"]
26 changes: 26 additions & 0 deletions py/selenium/webdriver/ie/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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.
#
# 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.

"""Type stub with lazy import mapping from __init__.py.

This stub file is necessary for type checkers and IDEs to automatically have
visibility into lazy modules since they are not imported immediately at runtime.
"""

from . import options, service, webdriver

__all__ = ["options", "service", "webdriver"]
26 changes: 26 additions & 0 deletions py/selenium/webdriver/safari/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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.
#
# 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.

"""Type stub with lazy import mapping from __init__.py.

This stub file is necessary for type checkers and IDEs to automatically have
visibility into lazy modules since they are not imported immediately at runtime.
"""

from . import options, permissions, remote_connection, service, webdriver

__all__ = ["options", "permissions", "remote_connection", "service", "webdriver"]
Loading
Loading