Skip to content

Commit be7d597

Browse files
Merge branch 'trunk' into refactor
2 parents 5434dd8 + f2d3870 commit be7d597

File tree

17 files changed

+528
-125
lines changed

17 files changed

+528
-125
lines changed

common/repositories.bzl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ js_library(
123123

124124
pkg_archive(
125125
name = "mac_edge",
126-
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/b405fb02-0c71-4762-be7f-08a88b17c176/MicrosoftEdge-135.0.3179.85.pkg",
127-
sha256 = "292b4794bc9452908d67971e04f5184c167316b2e0fcead3f5739c3738a358b6",
126+
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/784d0da7-3b50-4888-8a30-159d8af03e55/MicrosoftEdge-135.0.3179.98.pkg",
127+
sha256 = "fda91427e9172b704228f01a35f9a426479e9f5f592f6ff2de85e75ade0b25c8",
128128
move = {
129-
"MicrosoftEdge-135.0.3179.85.pkg/Payload/Microsoft Edge.app": "Edge.app",
129+
"MicrosoftEdge-135.0.3179.98.pkg/Payload/Microsoft Edge.app": "Edge.app",
130130
},
131131
build_file_content = """
132132
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -143,8 +143,8 @@ js_library(
143143

144144
deb_archive(
145145
name = "linux_edge",
146-
url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_135.0.3179.85-1_amd64.deb",
147-
sha256 = "c756292acbe3d89c75fd5135dde13f68292ff9beeb18e428e3171162ed864060",
146+
url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_135.0.3179.98-1_amd64.deb",
147+
sha256 = "0291339ce51e66b2987f6e5fc76c310b9a5c54c0d05c3f70b3cdda2743f6774e",
148148
build_file_content = """
149149
load("@aspect_rules_js//js:defs.bzl", "js_library")
150150
package(default_visibility = ["//visibility:public"])
@@ -165,8 +165,8 @@ js_library(
165165

166166
http_archive(
167167
name = "linux_edgedriver",
168-
url = "https://msedgedriver.azureedge.net/135.0.3179.85/edgedriver_linux64.zip",
169-
sha256 = "d05ef36fc3c6fdc4bc0b0c96a9fffc0ce0afd2289f08dfe2cd141d41e8dea195",
168+
url = "https://msedgedriver.azureedge.net/135.0.3179.98/edgedriver_linux64.zip",
169+
sha256 = "ea89d43034f86c70f37b9f580cd7bc5f18cb9537697af55e113b94c9dc766336",
170170
build_file_content = """
171171
load("@aspect_rules_js//js:defs.bzl", "js_library")
172172
package(default_visibility = ["//visibility:public"])
@@ -182,8 +182,8 @@ js_library(
182182

183183
http_archive(
184184
name = "mac_edgedriver",
185-
url = "https://msedgedriver.azureedge.net/135.0.3179.85/edgedriver_mac64.zip",
186-
sha256 = "9f9c59099b664c9c4a8f59d501e9fcf0dec3e4bfd860635669730a6e59d55ca9",
185+
url = "https://msedgedriver.azureedge.net/135.0.3179.98/edgedriver_mac64.zip",
186+
sha256 = "5b8b5e019e432b86e49a4e1d8f3a312373a0c7ad88b84ae2419419d100f99fdb",
187187
build_file_content = """
188188
load("@aspect_rules_js//js:defs.bzl", "js_library")
189189
package(default_visibility = ["//visibility:public"])
@@ -199,8 +199,8 @@ js_library(
199199

200200
http_archive(
201201
name = "linux_chrome",
202-
url = "https://storage.googleapis.com/chrome-for-testing-public/135.0.7049.97/linux64/chrome-linux64.zip",
203-
sha256 = "dca0a86931162c85fbd054cc037519fcf855dca912c7fd2dc2e2e48fb7d59961",
202+
url = "https://storage.googleapis.com/chrome-for-testing-public/135.0.7049.114/linux64/chrome-linux64.zip",
203+
sha256 = "dd86dbac5d1a362bf9d46818e21e4afe2e8b1b419e0810573d298842eef88b82",
204204
build_file_content = """
205205
load("@aspect_rules_js//js:defs.bzl", "js_library")
206206
package(default_visibility = ["//visibility:public"])
@@ -221,8 +221,8 @@ js_library(
221221

222222
http_archive(
223223
name = "mac_chrome",
224-
url = "https://storage.googleapis.com/chrome-for-testing-public/135.0.7049.97/mac-x64/chrome-mac-x64.zip",
225-
sha256 = "53880ac98a04490c647d1a5649eb0ebd8001741bb17501df34908e8826fe516f",
224+
url = "https://storage.googleapis.com/chrome-for-testing-public/135.0.7049.114/mac-x64/chrome-mac-x64.zip",
225+
sha256 = "e7deb29034368567bab7f5b24a7c09d329ef2023f61e6ed349b714abb80292c2",
226226
strip_prefix = "chrome-mac-x64",
227227
patch_cmds = [
228228
"mv 'Google Chrome for Testing.app' Chrome.app",
@@ -243,8 +243,8 @@ js_library(
243243

244244
http_archive(
245245
name = "linux_chromedriver",
246-
url = "https://storage.googleapis.com/chrome-for-testing-public/135.0.7049.97/linux64/chromedriver-linux64.zip",
247-
sha256 = "12a0e6e8035b3671a7a884e33949f1f5154d2d2ca68593715851f6f3a5e836ec",
246+
url = "https://storage.googleapis.com/chrome-for-testing-public/135.0.7049.114/linux64/chromedriver-linux64.zip",
247+
sha256 = "28ef94323503f927f8fca4650d5acf6325e69829720900cc696c3d8179ce855c",
248248
strip_prefix = "chromedriver-linux64",
249249
build_file_content = """
250250
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -261,8 +261,8 @@ js_library(
261261

262262
http_archive(
263263
name = "mac_chromedriver",
264-
url = "https://storage.googleapis.com/chrome-for-testing-public/135.0.7049.97/mac-x64/chromedriver-mac-x64.zip",
265-
sha256 = "2eedf6406ca4e9f11a4c196ce56e8d25c15dc68bd8ea07c7da8423d2327e9aa1",
264+
url = "https://storage.googleapis.com/chrome-for-testing-public/135.0.7049.114/mac-x64/chromedriver-mac-x64.zip",
265+
sha256 = "a1da3421971762c4d6f258fb8e49dfd3aa855387f0b82d0333a59e972feb21d9",
266266
strip_prefix = "chromedriver-mac-x64",
267267
build_file_content = """
268268
load("@aspect_rules_js//js:defs.bzl", "js_library")

py/conftest.py

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import pytest
2727

2828
from selenium import webdriver
29+
from selenium.webdriver.remote.server import Server
2930
from test.selenium.webdriver.common.network import get_lan_ip
3031
from test.selenium.webdriver.common.webserver import SimpleWebServer
3132

@@ -380,60 +381,26 @@ def server(request):
380381
yield None
381382
return
382383

383-
_host = "localhost"
384-
_port = 4444
385-
_path = os.path.join(
384+
jar_path = os.path.join(
386385
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
387386
"java/src/org/openqa/selenium/grid/selenium_server_deploy.jar",
388387
)
389388

390-
def wait_for_server(url, timeout):
391-
start = time.time()
392-
while time.time() - start < timeout:
393-
try:
394-
urlopen(url)
395-
return 1
396-
except OSError:
397-
time.sleep(0.2)
398-
return 0
399-
400-
_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
401-
url = f"http://{_host}:{_port}/status"
402-
try:
403-
_socket.connect((_host, _port))
404-
print(
405-
"The remote driver server is already running or something else"
406-
"is using port {}, continuing...".format(_port)
407-
)
408-
except Exception:
409-
remote_env = os.environ.copy()
410-
if platform.system() == "Linux":
411-
# There are issues with window size/position when running Firefox
412-
# under Wayland, so we use XWayland instead.
413-
remote_env["MOZ_ENABLE_WAYLAND"] = "0"
414-
print("Starting the Selenium server")
415-
process = subprocess.Popen(
416-
[
417-
"java",
418-
"-jar",
419-
_path,
420-
"standalone",
421-
"--port",
422-
"4444",
423-
"--selenium-manager",
424-
"true",
425-
"--enable-managed-downloads",
426-
"true",
427-
],
428-
env=remote_env,
429-
)
430-
print(f"Selenium server running as process: {process.pid}")
431-
assert wait_for_server(url, 10), f"Timed out waiting for Selenium server at {url}"
432-
print("Selenium server is ready")
433-
yield process
434-
process.terminate()
435-
process.wait()
436-
print("Selenium server has been terminated")
389+
remote_env = os.environ.copy()
390+
if platform.system() == "Linux":
391+
# There are issues with window size/position when running Firefox
392+
# under Wayland, so we use XWayland instead.
393+
remote_env["MOZ_ENABLE_WAYLAND"] = "0"
394+
395+
if os.path.exists(jar_path):
396+
# use the grid server built by bazel
397+
server = Server(path=jar_path, env=remote_env)
398+
else:
399+
# use the local grid server (downloads a new one if needed)
400+
server = Server(env=remote_env)
401+
server.start()
402+
yield server
403+
server.stop()
437404

438405

439406
@pytest.fixture(autouse=True, scope="session")
@@ -485,6 +452,13 @@ def clean_driver(request):
485452

486453
@pytest.fixture
487454
def firefox_options(request):
455+
try:
456+
driver_option = request.config.option.drivers[0]
457+
except (AttributeError, TypeError):
458+
raise Exception("This test requires a --driver to be specified")
459+
# skip tests in the 'remote' directory if run with a local driver
460+
if request.node.path.parts[-2] == "remote" and get_driver_class(driver_option) != "Remote":
461+
pytest.skip(f"Remote tests can't be run with driver '{driver_option}'")
488462
options = webdriver.FirefoxOptions()
489463
if request.config.option.headless:
490464
options.add_argument("-headless")

py/docs/source/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ Webdriver.remote
151151
selenium.webdriver.remote.mobile
152152
selenium.webdriver.remote.remote_connection
153153
selenium.webdriver.remote.script_key
154+
selenium.webdriver.remote.server
154155
selenium.webdriver.remote.shadowroot
155156
selenium.webdriver.remote.switch_to
156157
selenium.webdriver.remote.utils

py/selenium/webdriver/remote/client_config.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
1718
import base64
1819
import os
1920
import socket
@@ -96,24 +97,14 @@ def __init__(
9697
self.proxy = proxy
9798
self.ignore_certificates = ignore_certificates
9899
self.init_args_for_pool_manager = init_args_for_pool_manager or {}
99-
self.timeout = timeout
100+
self.timeout = socket.getdefaulttimeout() if timeout is None else timeout
100101
self.username = username
101102
self.password = password
102103
self.auth_type = auth_type
103104
self.token = token
104105
self.user_agent = user_agent
105106
self.extra_headers = extra_headers
106107

107-
self.timeout = (
108-
(
109-
float(os.getenv("GLOBAL_DEFAULT_TIMEOUT", str(socket.getdefaulttimeout())))
110-
if os.getenv("GLOBAL_DEFAULT_TIMEOUT") is not None
111-
else socket.getdefaulttimeout()
112-
)
113-
if timeout is None
114-
else timeout
115-
)
116-
117108
self.ca_certs = (
118109
(os.getenv("REQUESTS_CA_BUNDLE") if "REQUESTS_CA_BUNDLE" in os.environ else certifi.where())
119110
if ca_certs is None

py/selenium/webdriver/remote/remote_connection.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,7 @@ class RemoteConnection:
152152

153153
import certifi
154154

155-
_timeout = (
156-
float(os.getenv("GLOBAL_DEFAULT_TIMEOUT", str(socket.getdefaulttimeout())))
157-
if os.getenv("GLOBAL_DEFAULT_TIMEOUT") is not None
158-
else socket.getdefaulttimeout()
159-
)
155+
_timeout = socket.getdefaulttimeout()
160156
_ca_certs = os.getenv("REQUESTS_CA_BUNDLE") if "REQUESTS_CA_BUNDLE" in os.environ else certifi.where()
161157
_client_config: ClientConfig = None
162158

@@ -168,6 +164,10 @@ class RemoteConnection:
168164
extra_headers = None
169165
user_agent = f"selenium/{__version__} (python {system})"
170166

167+
@property
168+
def client_config(self):
169+
return self._client_config
170+
171171
@classmethod
172172
def get_timeout(cls):
173173
""":Returns:
@@ -176,7 +176,7 @@ def get_timeout(cls):
176176
Remote Connection
177177
"""
178178
warnings.warn(
179-
"get_timeout() in RemoteConnection is deprecated, get timeout from ClientConfig instance instead",
179+
"get_timeout() in RemoteConnection is deprecated, get timeout from client_config instead",
180180
DeprecationWarning,
181181
stacklevel=2,
182182
)
@@ -190,7 +190,7 @@ def set_timeout(cls, timeout):
190190
- timeout - timeout value for http requests in seconds
191191
"""
192192
warnings.warn(
193-
"set_timeout() in RemoteConnection is deprecated, set timeout to ClientConfig instance in constructor instead",
193+
"set_timeout() in RemoteConnection is deprecated, set timeout in client_config instead",
194194
DeprecationWarning,
195195
stacklevel=2,
196196
)
@@ -200,7 +200,7 @@ def set_timeout(cls, timeout):
200200
def reset_timeout(cls):
201201
"""Reset the http request timeout to socket._GLOBAL_DEFAULT_TIMEOUT."""
202202
warnings.warn(
203-
"reset_timeout() in RemoteConnection is deprecated, use reset_timeout() in ClientConfig instance instead",
203+
"reset_timeout() in RemoteConnection is deprecated, use reset_timeout() in client_config instead",
204204
DeprecationWarning,
205205
stacklevel=2,
206206
)
@@ -215,7 +215,7 @@ def get_certificate_bundle_path(cls):
215215
REQUESTS_CA_BUNDLE env variable if set.
216216
"""
217217
warnings.warn(
218-
"get_certificate_bundle_path() in RemoteConnection is deprecated, get ca_certs from ClientConfig instance instead",
218+
"get_certificate_bundle_path() in RemoteConnection is deprecated, get ca_certs from client_config instead",
219219
DeprecationWarning,
220220
stacklevel=2,
221221
)
@@ -231,7 +231,7 @@ def set_certificate_bundle_path(cls, path):
231231
- path - path of a .pem encoded certificate chain.
232232
"""
233233
warnings.warn(
234-
"set_certificate_bundle_path() in RemoteConnection is deprecated, set ca_certs to ClientConfig instance in constructor instead",
234+
"set_certificate_bundle_path() in RemoteConnection is deprecated, set ca_certs in client_config instead",
235235
DeprecationWarning,
236236
stacklevel=2,
237237
)
@@ -328,35 +328,35 @@ def __init__(
328328

329329
if remote_server_addr:
330330
warnings.warn(
331-
"setting remote_server_addr in RemoteConnection() is deprecated, set in ClientConfig instance instead",
331+
"setting remote_server_addr in RemoteConnection() is deprecated, set in client_config instead",
332332
DeprecationWarning,
333333
stacklevel=2,
334334
)
335335

336336
if not keep_alive:
337337
warnings.warn(
338-
"setting keep_alive in RemoteConnection() is deprecated, set in ClientConfig instance instead",
338+
"setting keep_alive in RemoteConnection() is deprecated, set in client_config instead",
339339
DeprecationWarning,
340340
stacklevel=2,
341341
)
342342

343343
if ignore_certificates:
344344
warnings.warn(
345-
"setting ignore_certificates in RemoteConnection() is deprecated, set in ClientConfig instance instead",
345+
"setting ignore_certificates in RemoteConnection() is deprecated, set in client_config instead",
346346
DeprecationWarning,
347347
stacklevel=2,
348348
)
349349

350350
if init_args_for_pool_manager:
351351
warnings.warn(
352-
"setting init_args_for_pool_manager in RemoteConnection() is deprecated, set in ClientConfig instance instead",
352+
"setting init_args_for_pool_manager in RemoteConnection() is deprecated, set in client_config instead",
353353
DeprecationWarning,
354354
stacklevel=2,
355355
)
356356

357357
if ignore_proxy:
358358
warnings.warn(
359-
"setting ignore_proxy in RemoteConnection() is deprecated, set in ClientConfig instance instead",
359+
"setting ignore_proxy in RemoteConnection() is deprecated, set in client_config instead",
360360
DeprecationWarning,
361361
stacklevel=2,
362362
)

0 commit comments

Comments
 (0)