Skip to content

Commit 63f26eb

Browse files
Merge branch 'trunk' into Fix15697-5
2 parents a46a37a + 1b7f3b0 commit 63f26eb

File tree

10 files changed

+114
-70
lines changed

10 files changed

+114
-70
lines changed

dotnet/src/webdriver/Proxy.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public class Proxy
7272
{
7373
private ProxyKind proxyKind = ProxyKind.Unspecified;
7474
private bool isAutoDetect;
75-
private string? ftpProxyLocation;
7675
private string? httpProxyLocation;
7776
private string? proxyAutoConfigUrl;
7877
private string? sslProxyLocation;
@@ -116,11 +115,6 @@ public Proxy(Dictionary<string, object> settings)
116115
}
117116
}
118117

119-
if (settings.TryGetValue("ftpProxy", out object? ftpProxyObj) && ftpProxyObj?.ToString() is string ftpProxy)
120-
{
121-
this.FtpProxy = ftpProxy;
122-
}
123-
124118
if (settings.TryGetValue("httpProxy", out object? httpProxyObj) && httpProxyObj?.ToString() is string httpProxy)
125119
{
126120
this.HttpProxy = httpProxy;
@@ -236,24 +230,6 @@ public bool IsAutoDetect
236230
}
237231
}
238232

239-
/// <summary>
240-
/// Gets or sets the value of the proxy for the FTP protocol.
241-
/// </summary>
242-
[JsonPropertyName("ftpProxy")]
243-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
244-
[Obsolete("FTP proxy support is deprecated and will be removed in the 4.37 version.")]
245-
public string? FtpProxy
246-
{
247-
get => this.ftpProxyLocation;
248-
249-
set
250-
{
251-
this.VerifyProxyTypeCompatilibily(ProxyKind.Manual);
252-
this.proxyKind = ProxyKind.Manual;
253-
this.ftpProxyLocation = value;
254-
}
255-
}
256-
257233
/// <summary>
258234
/// Gets or sets the value of the proxy for the HTTP protocol.
259235
/// </summary>
@@ -494,11 +470,6 @@ public void AddBypassAddresses(IEnumerable<string> addressesToAdd)
494470
serializedDictionary["sslProxy"] = this.sslProxyLocation;
495471
}
496472

497-
if (!string.IsNullOrEmpty(this.ftpProxyLocation))
498-
{
499-
serializedDictionary["ftpProxy"] = this.ftpProxyLocation;
500-
}
501-
502473
if (!string.IsNullOrEmpty(this.socksProxyLocation))
503474
{
504475
if (!this.socksVersion.HasValue)

dotnet/test/common/ProxyTest.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public void NotInitializedProxy()
3131
Proxy proxy = new Proxy();
3232

3333
Assert.That(proxy.Kind, Is.EqualTo(ProxyKind.Unspecified));
34-
Assert.That(proxy.FtpProxy, Is.Null);
3534
Assert.That(proxy.HttpProxy, Is.Null);
3635
Assert.That(proxy.SslProxy, Is.Null);
3736
Assert.That(proxy.SocksProxy, Is.Null);
@@ -54,7 +53,6 @@ public void CanNotChangeAlreadyInitializedProxyType()
5453
Assert.That(() => proxy.SocksUserName = "", Throws.InvalidOperationException);
5554
Assert.That(() => proxy.SocksProxy = "", Throws.InvalidOperationException);
5655
Assert.That(() => proxy.SocksVersion = 5, Throws.InvalidOperationException);
57-
Assert.That(() => proxy.FtpProxy = "", Throws.InvalidOperationException);
5856
Assert.That(() => proxy.HttpProxy = "", Throws.InvalidOperationException);
5957
Assert.That(() => proxy.SslProxy = "", Throws.InvalidOperationException);
6058
Assert.That(() => proxy.ProxyAutoConfigUrl = "", Throws.InvalidOperationException);
@@ -73,7 +71,6 @@ public void ManualProxy()
7371
Proxy proxy = new Proxy();
7472

7573
proxy.HttpProxy = "http.proxy:1234";
76-
proxy.FtpProxy = "ftp.proxy";
7774
proxy.SslProxy = "ssl.proxy";
7875
proxy.AddBypassAddresses("localhost", "127.0.0.*");
7976
proxy.SocksProxy = "socks.proxy:65555";
@@ -82,7 +79,6 @@ public void ManualProxy()
8279
proxy.SocksPassword = "test2";
8380

8481
Assert.That(proxy.Kind, Is.EqualTo(ProxyKind.Manual));
85-
Assert.That(proxy.FtpProxy, Is.EqualTo("ftp.proxy"));
8682
Assert.That(proxy.HttpProxy, Is.EqualTo("http.proxy:1234"));
8783
Assert.That(proxy.SslProxy, Is.EqualTo("ssl.proxy"));
8884
Assert.That(proxy.SocksProxy, Is.EqualTo("socks.proxy:65555"));
@@ -104,7 +100,6 @@ public void PACProxy()
104100
Assert.That(proxy.Kind, Is.EqualTo(ProxyKind.ProxyAutoConfigure));
105101
Assert.That(proxy.ProxyAutoConfigUrl, Is.EqualTo("http://aaa/bbb.pac"));
106102

107-
Assert.That(proxy.FtpProxy, Is.Null);
108103
Assert.That(proxy.HttpProxy, Is.Null);
109104
Assert.That(proxy.SslProxy, Is.Null);
110105
Assert.That(proxy.SocksProxy, Is.Null);
@@ -124,7 +119,6 @@ public void AutoDetectProxy()
124119
Assert.That(proxy.Kind, Is.EqualTo(ProxyKind.AutoDetect));
125120
Assert.That(proxy.IsAutoDetect, Is.True);
126121

127-
Assert.That(proxy.FtpProxy, Is.Null);
128122
Assert.That(proxy.HttpProxy, Is.Null);
129123
Assert.That(proxy.SslProxy, Is.Null);
130124
Assert.That(proxy.SocksProxy, Is.Null);
@@ -153,7 +147,6 @@ public void ManualProxyFromDictionary()
153147
Proxy proxy = new Proxy(proxyData);
154148

155149
Assert.That(proxy.Kind, Is.EqualTo(ProxyKind.Manual));
156-
Assert.That(proxy.FtpProxy, Is.EqualTo("ftp.proxy"));
157150
Assert.That(proxy.HttpProxy, Is.EqualTo("http.proxy:1234"));
158151
Assert.That(proxy.SslProxy, Is.EqualTo("ssl.proxy"));
159152
Assert.That(proxy.SocksProxy, Is.EqualTo("socks.proxy:65555"));
@@ -199,7 +192,6 @@ public void PacProxyFromDictionary()
199192
Assert.That(proxy.Kind, Is.EqualTo(ProxyKind.ProxyAutoConfigure));
200193
Assert.That(proxy.ProxyAutoConfigUrl, Is.EqualTo("http://aaa/bbb.pac"));
201194

202-
Assert.That(proxy.FtpProxy, Is.Null);
203195
Assert.That(proxy.HttpProxy, Is.Null);
204196
Assert.That(proxy.SslProxy, Is.Null);
205197
Assert.That(proxy.SocksProxy, Is.Null);
@@ -222,7 +214,6 @@ public void AutoDetectProxyFromDictionary()
222214
Assert.That(proxy.Kind, Is.EqualTo(ProxyKind.AutoDetect));
223215
Assert.That(proxy.IsAutoDetect, Is.True);
224216

225-
Assert.That(proxy.FtpProxy, Is.Null);
226217
Assert.That(proxy.HttpProxy, Is.Null);
227218
Assert.That(proxy.SslProxy, Is.Null);
228219
Assert.That(proxy.SocksProxy, Is.Null);
@@ -243,7 +234,6 @@ public void SystemProxyFromDictionary()
243234

244235
Assert.That(proxy.Kind, Is.EqualTo(ProxyKind.System));
245236

246-
Assert.That(proxy.FtpProxy, Is.Null);
247237
Assert.That(proxy.HttpProxy, Is.Null);
248238
Assert.That(proxy.SslProxy, Is.Null);
249239
Assert.That(proxy.SocksProxy, Is.Null);
@@ -265,7 +255,6 @@ public void DirectProxyFromDictionary()
265255

266256
Assert.That(proxy.Kind, Is.EqualTo(ProxyKind.Direct));
267257

268-
Assert.That(proxy.FtpProxy, Is.Null);
269258
Assert.That(proxy.HttpProxy, Is.Null);
270259
Assert.That(proxy.SslProxy, Is.Null);
271260
Assert.That(proxy.SocksProxy, Is.Null);
@@ -281,13 +270,11 @@ public void DirectProxyFromDictionary()
281270
public void ConstructingWithNullKeysWorksAsExpected()
282271
{
283272
Dictionary<string, object> rawProxy = new Dictionary<string, object>();
284-
rawProxy.Add("ftpProxy", null);
285273
rawProxy.Add("httpProxy", "http://www.example.com");
286274
rawProxy.Add("autodetect", null);
287275

288276
Proxy proxy = new Proxy(rawProxy);
289277

290-
Assert.That(proxy.FtpProxy, Is.Null);
291278
Assert.That(proxy.IsAutoDetect, Is.False);
292279
Assert.That(proxy.HttpProxy, Is.EqualTo("http://www.example.com"));
293280
}

java/src/org/openqa/selenium/remote/RemoteWebDriver.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,14 @@ protected Response execute(CommandPayload payload) {
572572
if (e instanceof SessionNotCreatedException) {
573573
toThrow = (WebDriverException) e;
574574
} else {
575+
// When this exception comes from a remote end, the real cause is usually hidden in the
576+
// cause. Let's try to rescue it and display it at the top level.
577+
String cause = e.getCause() != null ? " " + e.getCause().getMessage() : "";
575578
toThrow =
576579
new SessionNotCreatedException(
577580
"Possible causes are invalid address of the remote server or browser start-up"
578-
+ " failure.",
581+
+ " failure."
582+
+ cause,
579583
e);
580584
}
581585
} else if (e instanceof WebDriverException) {

py/conftest.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ def firefox_options(request):
489489
except (AttributeError, TypeError):
490490
raise Exception("This test requires a --driver to be specified")
491491

492+
# skip if not Firefox or Remote
493+
if driver_class not in ("firefox", "remote"):
494+
pytest.skip(f"This test requires Firefox or Remote. Got {driver_class}")
495+
492496
# skip tests in the 'remote' directory if run with a local driver
493497
if request.node.path.parts[-2] == "remote" and getattr(_supported_drivers, driver_class) != "Remote":
494498
pytest.skip(f"Remote tests can't be run with driver '{driver_class}'")
@@ -506,15 +510,17 @@ def chromium_options(request):
506510
except (AttributeError, TypeError):
507511
raise Exception("This test requires a --driver to be specified")
508512

509-
# Skip if not Chrome or Edge
510-
if driver_class not in ("chrome", "edge"):
511-
pytest.skip(f"This test requires Chrome or Edge, got {driver_class}")
513+
# skip if not Chrome, Edge, or Remote
514+
if driver_class not in ("chrome", "edge", "remote"):
515+
pytest.skip(f"This test requires Chrome, Edge, or Remote. Got {driver_class}")
512516

513517
# skip tests in the 'remote' directory if run with a local driver
514518
if request.node.path.parts[-2] == "remote" and getattr(_supported_drivers, driver_class) != "Remote":
515519
pytest.skip(f"Remote tests can't be run with driver '{driver_class}'")
516520

517-
if driver_class in ("chrome", "edge"):
518-
options = Driver.clean_options(driver_class, request)
521+
if driver_class in ("chrome", "remote"):
522+
options = Driver.clean_options("chrome", request)
523+
else:
524+
options = Driver.clean_options("edge", request)
519525

520526
return options

py/selenium/webdriver/remote/client_config.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,19 @@ class ClientConfig:
5050
keep_alive = _ClientConfigDescriptor("_keep_alive")
5151
"""Gets and Sets Keep Alive value."""
5252
proxy = _ClientConfigDescriptor("_proxy")
53-
"""Gets and Sets the proxy used for communicating to the driver/server."""
53+
"""Gets and Sets the proxy used for communicating with the driver/server."""
5454
ignore_certificates = _ClientConfigDescriptor("_ignore_certificates")
5555
"""Gets and Sets the ignore certificate check value."""
5656
init_args_for_pool_manager = _ClientConfigDescriptor("_init_args_for_pool_manager")
5757
"""Gets and Sets the ignore certificate check."""
5858
timeout = _ClientConfigDescriptor("_timeout")
59-
"""Gets and Sets the timeout (in seconds) used for communicating to the
60-
driver/server."""
59+
"""Gets and Sets the timeout (in seconds) used for communicating with the driver/server."""
6160
ca_certs = _ClientConfigDescriptor("_ca_certs")
6261
"""Gets and Sets the path to bundle of CA certificates."""
6362
username = _ClientConfigDescriptor("_username")
64-
"""Gets and Sets the username used for basic authentication to the
65-
remote."""
63+
"""Gets and Sets the username used for basic authentication to the remote."""
6664
password = _ClientConfigDescriptor("_password")
67-
"""Gets and Sets the password used for basic authentication to the
68-
remote."""
65+
"""Gets and Sets the password used for basic authentication to the remote."""
6966
auth_type = _ClientConfigDescriptor("_auth_type")
7067
"""Gets and Sets the type of authentication to the remote server."""
7168
token = _ClientConfigDescriptor("_token")
@@ -74,6 +71,10 @@ class ClientConfig:
7471
"""Gets and Sets user agent to be added to the request headers."""
7572
extra_headers = _ClientConfigDescriptor("_extra_headers")
7673
"""Gets and Sets extra headers to be added to the request."""
74+
websocket_timeout = _ClientConfigDescriptor("_websocket_timeout")
75+
"""Gets and Sets the WebSocket response wait timeout (in seconds) used for communicating with the browser."""
76+
websocket_interval = _ClientConfigDescriptor("_websocket_interval")
77+
"""Gets and Sets the WebSocket response wait interval (in seconds) used for communicating with the browser."""
7778

7879
def __init__(
7980
self,
@@ -90,6 +91,8 @@ def __init__(
9091
token: Optional[str] = None,
9192
user_agent: Optional[str] = None,
9293
extra_headers: Optional[dict] = None,
94+
websocket_timeout: Optional[float] = 30.0,
95+
websocket_interval: Optional[float] = 0.1,
9396
) -> None:
9497
self.remote_server_addr = remote_server_addr
9598
self.keep_alive = keep_alive
@@ -103,6 +106,8 @@ def __init__(
103106
self.token = token
104107
self.user_agent = user_agent
105108
self.extra_headers = extra_headers
109+
self.websocket_timeout = websocket_timeout
110+
self.websocket_interval = websocket_interval
106111

107112
self.ca_certs = (
108113
(os.getenv("REQUESTS_CA_BUNDLE") if "REQUESTS_CA_BUNDLE" in os.environ else certifi.where())

py/selenium/webdriver/remote/webdriver.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,11 @@ def start_devtools(self):
12111211
return self._devtools, self._websocket_connection
12121212
if self.caps["browserName"].lower() == "firefox":
12131213
raise RuntimeError("CDP support for Firefox has been removed. Please switch to WebDriver BiDi.")
1214-
self._websocket_connection = WebSocketConnection(ws_url)
1214+
self._websocket_connection = WebSocketConnection(
1215+
ws_url,
1216+
self.command_executor.client_config.websocket_timeout,
1217+
self.command_executor.client_config.websocket_interval,
1218+
)
12151219
targets = self._websocket_connection.execute(self._devtools.target.get_targets())
12161220
for target in targets:
12171221
if target.target_id == self.current_window_handle:
@@ -1260,7 +1264,11 @@ def _start_bidi(self):
12601264
else:
12611265
raise WebDriverException("Unable to find url to connect to from capabilities")
12621266

1263-
self._websocket_connection = WebSocketConnection(ws_url)
1267+
self._websocket_connection = WebSocketConnection(
1268+
ws_url,
1269+
self.command_executor.client_config.websocket_timeout,
1270+
self.command_executor.client_config.websocket_interval,
1271+
)
12641272

12651273
@property
12661274
def network(self):

py/selenium/webdriver/remote/websocket_connection.py

Lines changed: 14 additions & 9 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 json
1819
import logging
1920
from ssl import CERT_NONE
@@ -28,16 +29,20 @@
2829

2930

3031
class WebSocketConnection:
31-
_response_wait_timeout = 30
32-
_response_wait_interval = 0.1
33-
3432
_max_log_message_size = 9999
3533

36-
def __init__(self, url):
37-
self.callbacks = {}
38-
self.session_id = None
34+
def __init__(self, url, timeout, interval):
35+
if not isinstance(timeout, (int, float)) or timeout < 0:
36+
raise WebDriverException("timeout must be a positive number")
37+
if not isinstance(interval, (int, float)) or timeout < 0:
38+
raise WebDriverException("interval must be a positive number")
39+
3940
self.url = url
41+
self.response_wait_timeout = timeout
42+
self.response_wait_interval = interval
4043

44+
self.callbacks = {}
45+
self.session_id = None
4146
self._id = 0
4247
self._messages = {}
4348
self._started = False
@@ -46,7 +51,7 @@ def __init__(self, url):
4651
self._wait_until(lambda: self._started)
4752

4853
def close(self):
49-
self._ws_thread.join(timeout=self._response_wait_timeout)
54+
self._ws_thread.join(timeout=self.response_wait_timeout)
5055
self._ws.close()
5156
self._started = False
5257
self._ws = None
@@ -142,8 +147,8 @@ def _process_message(self, message):
142147
Thread(target=callback, args=(params,)).start()
143148

144149
def _wait_until(self, condition):
145-
timeout = self._response_wait_timeout
146-
interval = self._response_wait_interval
150+
timeout = self.response_wait_timeout
151+
interval = self.response_wait_interval
147152

148153
while timeout > 0:
149154
result = condition()

0 commit comments

Comments
 (0)