Skip to content

Commit e922470

Browse files
authored
Merge branch 'trunk' into remove-py2.x-test
2 parents 9a69dd6 + d1836b2 commit e922470

File tree

7 files changed

+38
-25
lines changed

7 files changed

+38
-25
lines changed

dotnet/src/webdriver/BiDi/Communication/Transport/WebSocketTransport.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ public class WebSocketTransport(Uri _uri) : ITransport, IDisposable
1616
private readonly ClientWebSocket _webSocket = new();
1717
private readonly ArraySegment<byte> _receiveBuffer = new(new byte[1024 * 8]);
1818

19+
private readonly SemaphoreSlim _socketSendSemaphoreSlim = new(1, 1);
20+
1921
public async Task ConnectAsync(CancellationToken cancellationToken)
2022
{
21-
_webSocket.Options.SetBuffer(_receiveBuffer.Count, _receiveBuffer.Count, _receiveBuffer);
2223
await _webSocket.ConnectAsync(_uri, cancellationToken).ConfigureAwait(false);
2324
}
2425

@@ -32,8 +33,9 @@ public async Task<T> ReceiveAsJsonAsync<T>(JsonSerializerOptions jsonSerializerO
3233
{
3334
result = await _webSocket.ReceiveAsync(_receiveBuffer, cancellationToken).ConfigureAwait(false);
3435

35-
await ms.WriteAsync(_receiveBuffer.Array!, _receiveBuffer.Offset, result.Count).ConfigureAwait(false);
36-
} while (!result.EndOfMessage);
36+
await ms.WriteAsync(_receiveBuffer.Array!, _receiveBuffer.Offset, result.Count, cancellationToken).ConfigureAwait(false);
37+
}
38+
while (!result.EndOfMessage);
3739

3840
ms.Seek(0, SeekOrigin.Begin);
3941

@@ -51,12 +53,21 @@ public async Task SendAsJsonAsync(Command command, JsonSerializerOptions jsonSer
5153
{
5254
var buffer = JsonSerializer.SerializeToUtf8Bytes(command, typeof(Command), jsonSerializerOptions);
5355

54-
if (_logger.IsEnabled(LogEventLevel.Trace))
56+
await _socketSendSemaphoreSlim.WaitAsync(cancellationToken);
57+
58+
try
5559
{
56-
_logger.Trace($"BiDi SND >> {buffer.Length} > {Encoding.UTF8.GetString(buffer)}");
57-
}
60+
if (_logger.IsEnabled(LogEventLevel.Trace))
61+
{
62+
_logger.Trace($"BiDi SND >> {buffer.Length} > {Encoding.UTF8.GetString(buffer)}");
63+
}
5864

59-
await _webSocket.SendAsync(new ArraySegment<byte>(buffer), WebSocketMessageType.Text, true, cancellationToken).ConfigureAwait(false);
65+
await _webSocket.SendAsync(new ArraySegment<byte>(buffer), WebSocketMessageType.Text, true, cancellationToken).ConfigureAwait(false);
66+
}
67+
finally
68+
{
69+
_socketSendSemaphoreSlim.Release();
70+
}
6071
}
6172

6273
public void Dispose()

dotnet/src/webdriver/Remote/HttpCommandExecutor.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using System;
2222
using System.Collections.Generic;
2323
using System.Globalization;
24+
using System.Linq;
2425
using System.Net;
2526
using System.Net.Http;
2627
using System.Net.Http.Headers;
@@ -417,7 +418,11 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
417418
var responseTask = base.SendAsync(request, cancellationToken);
418419

419420
StringBuilder requestLogMessageBuilder = new();
420-
requestLogMessageBuilder.AppendFormat(">> {0}", request);
421+
requestLogMessageBuilder.AppendFormat(">> {0} RequestUri: {1}, Content: {2}, Headers: {3}",
422+
request.Method,
423+
request.RequestUri?.ToString() ?? "null",
424+
request.Content?.ToString() ?? "null",
425+
request.Headers?.Count());
421426

422427
if (request.Content != null)
423428
{
@@ -430,7 +435,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
430435
var response = await responseTask.ConfigureAwait(false);
431436

432437
StringBuilder responseLogMessageBuilder = new();
433-
responseLogMessageBuilder.AppendFormat("<< {0}", response);
438+
responseLogMessageBuilder.AppendFormat("<< StatusCode: {0}, ReasonPhrase: {1}, Content: {2}, Headers: {3}", (int)response.StatusCode, response.ReasonPhrase, response.Content, response.Headers?.Count());
434439

435440
if (!response.IsSuccessStatusCode && response.Content != null)
436441
{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
public class HttpCommandExecutor implements CommandExecutor, NeedsLocalLogs {
4545

4646
private final URL remoteServer;
47-
private final HttpClient client;
47+
public final HttpClient client;
4848
private final HttpClient.Factory httpClientFactory;
4949
private final Map<String, CommandInfo> additionalCommands;
50-
private CommandCodec<HttpRequest> commandCodec;
51-
private ResponseCodec<HttpResponse> responseCodec;
50+
protected CommandCodec<HttpRequest> commandCodec;
51+
protected ResponseCodec<HttpResponse> responseCodec;
5252

5353
private LocalLogs logs = LocalLogs.getNullLogger();
5454

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public class RemoteWebDriver
118118
private Level level = Level.FINE;
119119
private ErrorHandler errorHandler = new ErrorHandler();
120120
private CommandExecutor executor;
121-
private Capabilities capabilities;
121+
protected Capabilities capabilities;
122122
private SessionId sessionId;
123123
private FileDetector fileDetector = new UselessFileDetector();
124124
private ExecuteMethod executeMethod;

java/src/org/openqa/selenium/remote/service/DriverService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ private enum StartOrDie {
355355
public abstract static class Builder<DS extends DriverService, B extends Builder<?, ?>> {
356356

357357
private int port = 0;
358-
private File exe = null;
358+
public File exe = null;
359359
private Map<String, String> environment = emptyMap();
360360
private File logFile;
361361
private Duration timeout;

java/src/org/openqa/selenium/support/ui/FluentWait.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ public class FluentWait<T> implements Wait<T> {
6666

6767
private static final Duration DEFAULT_WAIT_DURATION = Duration.ofMillis(DEFAULT_SLEEP_TIMEOUT);
6868

69-
private final T input;
70-
private final java.time.Clock clock;
71-
private final Sleeper sleeper;
69+
protected final T input;
70+
protected final java.time.Clock clock;
71+
protected final Sleeper sleeper;
7272

73-
private Duration timeout = DEFAULT_WAIT_DURATION;
74-
private Duration interval = DEFAULT_WAIT_DURATION;
75-
private Supplier<String> messageSupplier = () -> null;
73+
protected Duration timeout = DEFAULT_WAIT_DURATION;
74+
protected Duration interval = DEFAULT_WAIT_DURATION;
75+
protected Supplier<String> messageSupplier = () -> null;
7676

77-
private final List<Class<? extends Throwable>> ignoredExceptions = new ArrayList<>();
77+
protected final List<Class<? extends Throwable>> ignoredExceptions = new ArrayList<>();
7878

7979
/**
8080
* @param input The input value to pass to the evaluated conditions.

py/test/selenium/webdriver/common/network.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525

2626
def get_interface_ip(ifname):
2727
def _bytes(value, encoding):
28-
try:
29-
return bytes(value, encoding) # Python 3
30-
except TypeError:
31-
return value # Python 2
28+
return bytes(value, encoding)
3229

3330
sckt = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
3431
return socket.inet_ntoa(

0 commit comments

Comments
 (0)