Skip to content

Commit 378328a

Browse files
authored
Merge branch 'trunk' into issue-13793
2 parents 25e3bfe + 2dcac9f commit 378328a

File tree

12 files changed

+4315
-1171
lines changed

12 files changed

+4315
-1171
lines changed

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ rules_closure_toolchains()
3434

3535
http_archive(
3636
name = "rules_rust",
37-
integrity = "sha256-JLN47ZcAbx9wEr5Jiib4HduZATGLiDgK7oUi/fvotzU=",
38-
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.42.1/rules_rust-v0.42.1.tar.gz"],
37+
integrity = "sha256-Zx3bP+Xrz53TTQUeynNS+68z+lO/Ye7Qt1pMNIKeVIA=",
38+
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.52.2/rules_rust-v0.52.2.tar.gz"],
3939
)
4040

4141
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")

dotnet/src/webdriver/PrintOptions.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,27 @@ public bool ShrinkToFit
101101
}
102102

103103
/// <summary>
104-
/// Gets the dimensions for each page in the printed document.
104+
/// Gets or sets the dimensions for each page in the printed document.
105105
/// </summary>
106106
public PageSize PageDimensions
107107
{
108108
get { return pageSize; }
109+
set
110+
{
111+
pageSize = value ?? throw new ArgumentNullException(nameof(value));
112+
}
109113
}
110114

111115
/// <summary>
112-
/// Gets the margins for each page in the doucment.
116+
/// Gets or sets the margins for each page in the doucment.
113117
/// </summary>
114118
public Margins PageMargins
115119
{
116120
get { return margins; }
121+
set
122+
{
123+
margins = value ?? throw new ArgumentNullException(nameof(value));
124+
}
117125
}
118126

119127
/// <summary>

dotnet/test/common/DriverTestFixture.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public abstract class DriverTestFixture
8888
public string scrollFrameOutOfViewport = EnvironmentManager.Instance.UrlBuilder.WhereIs("scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html");
8989
public string scrollFrameInViewport = EnvironmentManager.Instance.UrlBuilder.WhereIs("scrolling_tests/frame_with_nested_scrolling_frame.html");
9090

91+
public string printPage = EnvironmentManager.Instance.UrlBuilder.WhereIs("printPage.html");
92+
9193
protected IWebDriver driver;
9294

9395
public IWebDriver DriverInstance

dotnet/test/common/PrintTest.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using NUnit.Framework;
2+
using System;
3+
4+
namespace OpenQA.Selenium
5+
{
6+
[TestFixture]
7+
public class PrintTest : DriverTestFixture
8+
{
9+
private const string MagicString = "JVBER";
10+
private ISupportsPrint printer;
11+
12+
[SetUp]
13+
public void LocalSetUp()
14+
{
15+
Assert.That(driver, Is.InstanceOf<ISupportsPrint>(), $"Driver does not support {nameof(ISupportsPrint)}.");
16+
17+
printer = driver as ISupportsPrint;
18+
19+
driver.Navigate().GoToUrl(this.printPage);
20+
}
21+
22+
[Test]
23+
public void CanPrintPage()
24+
{
25+
var pdf = printer.Print(new PrintOptions());
26+
27+
Assert.That(pdf.AsBase64EncodedString, Does.Contain(MagicString));
28+
}
29+
30+
[Test]
31+
public void CanPrintTwoPages()
32+
{
33+
var options = new PrintOptions();
34+
35+
options.AddPageRangeToPrint("1-2");
36+
37+
var pdf = printer.Print(options);
38+
39+
Assert.That(pdf.AsBase64EncodedString, Does.Contain(MagicString));
40+
}
41+
42+
[Test]
43+
public void CanPrintWithMostParams()
44+
{
45+
var options = new PrintOptions()
46+
{
47+
Orientation = PrintOrientation.Landscape,
48+
ScaleFactor = 0.5,
49+
PageDimensions = new PrintOptions.PageSize { Width = 200, Height = 100 },
50+
PageMargins = new PrintOptions.Margins { Top = 1, Bottom = 1, Left = 2, Right = 2 },
51+
OutputBackgroundImages = true,
52+
ShrinkToFit = false
53+
};
54+
55+
options.AddPageRangeToPrint("1-3");
56+
57+
var pdf = printer.Print(options);
58+
59+
Assert.That(pdf.AsBase64EncodedString, Does.Contain(MagicString));
60+
}
61+
62+
[Test]
63+
public void PageSizeCannotBeNull()
64+
{
65+
Assert.That(() => new PrintOptions { PageDimensions = null }, Throws.InstanceOf<ArgumentNullException>());
66+
}
67+
68+
[Test]
69+
public void MarginsCannotBeNull()
70+
{
71+
Assert.That(() => new PrintOptions { PageMargins = null }, Throws.InstanceOf<ArgumentNullException>());
72+
}
73+
}
74+
}

java/src/org/openqa/selenium/grid/data/NodeStatus.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ public boolean equals(Object o) {
214214
return Objects.equals(this.nodeId, that.nodeId)
215215
&& Objects.equals(this.externalUri, that.externalUri)
216216
&& this.maxSessionCount == that.maxSessionCount
217-
&& this.sessionTimeout == that.sessionTimeout
217+
&& this.sessionTimeout.compareTo(that.sessionTimeout) == 0
218+
&& this.heartbeatPeriod.compareTo(that.heartbeatPeriod) == 0
218219
&& Objects.equals(this.slots, that.slots)
219220
&& Objects.equals(this.availability, that.availability)
220221
&& Objects.equals(this.version, that.version);

java/src/org/openqa/selenium/grid/router/GridStatusHandler.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,19 @@ public HttpResponse execute(HttpRequest req) {
135135

136136
List<Map<String, Object>> nodeResults =
137137
status.getNodes().stream()
138-
.map(node -> new ImmutableMap.Builder<String, Object>().putAll(node.toJson()).build())
138+
.map(
139+
node ->
140+
new ImmutableMap.Builder<String, Object>()
141+
.put("id", node.getNodeId())
142+
.put("uri", node.getExternalUri())
143+
.put("maxSessions", node.getMaxSessionCount())
144+
.put("sessionTimeout", node.getSessionTimeout().toMillis())
145+
.put("osInfo", node.getOsInfo())
146+
.put("heartbeatPeriod", node.getHeartbeatPeriod().toMillis())
147+
.put("availability", node.getAvailability())
148+
.put("version", node.getVersion())
149+
.put("slots", node.getSlots())
150+
.build())
139151
.collect(toList());
140152

141153
ImmutableMap.Builder<String, Object> value = ImmutableMap.builder();

java/test/org/openqa/selenium/grid/distributor/local/LocalDistributorTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public void setUp() throws URISyntaxException {
103103
.add(caps, new TestSessionFactory((id, c) -> new Handler(c)))
104104
.maximumConcurrentSessions(2)
105105
.sessionTimeout(Duration.ofSeconds(30))
106+
.heartbeatPeriod(Duration.ofSeconds(5))
106107
.build();
107108

108109
wait =
@@ -145,6 +146,7 @@ void testAddNodeToDistributor() {
145146
assertThat(distributorNode.getNodeId()).isEqualByComparingTo(localNode.getId());
146147
assertThat(distributorNode.getExternalUri()).isEqualTo(uri);
147148
assertThat(distributorNode.getSessionTimeout()).isEqualTo(Duration.ofSeconds(30));
149+
assertThat(distributorNode.getHeartbeatPeriod()).isEqualTo(Duration.ofSeconds(5));
148150
}
149151

150152
@Test

java/test/org/openqa/selenium/grid/gridui/OverallGridTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void tearDown() {
6868

6969
@Test
7070
void shouldReportConcurrencyZeroPercentWhenGridIsStartedWithoutLoad() {
71-
driver.get(whereIs(server, "/ui#/sessions"));
71+
driver.get(whereIs(server, "/ui/#/sessions"));
7272

7373
WebElement concurrency =
7474
wait.until(
@@ -79,7 +79,7 @@ void shouldReportConcurrencyZeroPercentWhenGridIsStartedWithoutLoad() {
7979

8080
@Test
8181
void shouldShowOneNodeRegistered() {
82-
driver.get(whereIs(server, "/ui"));
82+
driver.get(whereIs(server, "/ui/"));
8383

8484
List<WebElement> nodeInfoIcons =
8585
wait.until(
@@ -93,7 +93,7 @@ void shouldIncrementSessionCountWhenSessionStarts() {
9393
WebDriver remoteWebDriver =
9494
new RemoteWebDriver(server.getUrl(), Browser.detect().getCapabilities());
9595
try {
96-
driver.get(whereIs(server, "/ui#/sessions"));
96+
driver.get(whereIs(server, "/ui/#/sessions"));
9797

9898
wait.until(textToBe(By.cssSelector("div[data-testid='session-count']"), "1"));
9999
} finally {

py/selenium/webdriver/safari/service.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Service(service.Service):
2828
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
2929
:param service_args: (Optional) List of args to be passed to the subprocess when launching the executable.
3030
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
31+
:param enable_logging: (Optional) Enable logging of the service. Logs can be located at `~/Library/Logs/com.apple.WebDriver/`
3132
"""
3233

3334
def __init__(
@@ -37,12 +38,16 @@ def __init__(
3738
service_args: typing.Optional[typing.List[str]] = None,
3839
env: typing.Optional[typing.Mapping[str, str]] = None,
3940
reuse_service=False,
41+
enable_logging: bool = False,
4042
driver_path_env_key: str = None,
4143
**kwargs,
4244
) -> None:
4345
self.service_args = service_args or []
4446
driver_path_env_key = driver_path_env_key or "SE_SAFARIDRIVER"
4547

48+
if enable_logging:
49+
self.service_args.append("--diagnose")
50+
4651
self.reuse_service = reuse_service
4752
super().__init__(
4853
executable_path=executable_path,

0 commit comments

Comments
 (0)