Skip to content

Commit 8425661

Browse files
authored
Merge branch 'trunk' into add_set_cache_behaviour
2 parents d2bebe2 + 65af639 commit 8425661

File tree

10 files changed

+104
-39
lines changed

10 files changed

+104
-39
lines changed

dotnet/src/webdriver/Cookie.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public static Cookie FromDictionary(Dictionary<string, object> rawCookie)
277277
{
278278
if (rawCookie == null)
279279
{
280-
throw new ArgumentNullException(nameof(rawCookie), "Dictionary cannot be null");
280+
throw new ArgumentNullException(nameof(rawCookie));
281281
}
282282

283283
string name = rawCookie["name"].ToString();

dotnet/src/webdriver/CookieJar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void DeleteAllCookies()
127127
{
128128
var rawCookie = driver.InternalExecute(DriverCommand.GetCookie, new() { { "name", name } }).Value;
129129

130-
return Cookie.FromDictionary((Dictionary<string, object>)rawCookie);
130+
return Cookie.FromDictionary((Dictionary<string, object>)rawCookie!);
131131
}
132132
catch (NoSuchCookieException)
133133
{

dotnet/src/webdriver/DevTools/v130/V130Target.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ private void OnDetachedFromTarget(object sender, DetachedFromTargetEventArgs e)
125125
private void OnAttachedToTarget(object sender, AttachedToTargetEventArgs e)
126126
{
127127
var targetInfo = e.TargetInfo == null ? null : new TargetInfo
128-
{
129-
BrowserContextId = e.TargetInfo.BrowserContextId,
130-
IsAttached = e.TargetInfo.Attached,
131-
OpenerId = e.TargetInfo.OpenerId,
132-
TargetId = e.TargetInfo.TargetId,
133-
Title = e.TargetInfo.Title,
134-
Type = e.TargetInfo.Type,
135-
Url = e.TargetInfo.Url
128+
{
129+
BrowserContextId = e.TargetInfo.BrowserContextId,
130+
IsAttached = e.TargetInfo.Attached,
131+
OpenerId = e.TargetInfo.OpenerId,
132+
TargetId = e.TargetInfo.TargetId,
133+
Title = e.TargetInfo.Title,
134+
Type = e.TargetInfo.Type,
135+
Url = e.TargetInfo.Url
136136
};
137137

138138
this.OnTargetAttached(new TargetAttachedEventArgs

dotnet/src/webdriver/DevTools/v131/V131Target.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ private void OnDetachedFromTarget(object sender, DetachedFromTargetEventArgs e)
125125
private void OnAttachedToTarget(object sender, AttachedToTargetEventArgs e)
126126
{
127127
var targetInfo = e.TargetInfo == null ? null : new TargetInfo
128-
{
129-
BrowserContextId = e.TargetInfo.BrowserContextId,
130-
IsAttached = e.TargetInfo.Attached,
131-
OpenerId = e.TargetInfo.OpenerId,
132-
TargetId = e.TargetInfo.TargetId,
133-
Title = e.TargetInfo.Title,
134-
Type = e.TargetInfo.Type,
135-
Url = e.TargetInfo.Url
128+
{
129+
BrowserContextId = e.TargetInfo.BrowserContextId,
130+
IsAttached = e.TargetInfo.Attached,
131+
OpenerId = e.TargetInfo.OpenerId,
132+
TargetId = e.TargetInfo.TargetId,
133+
Title = e.TargetInfo.Title,
134+
Type = e.TargetInfo.Type,
135+
Url = e.TargetInfo.Url
136136
};
137137

138138
this.OnTargetAttached(new TargetAttachedEventArgs

dotnet/src/webdriver/DevTools/v132/V132Target.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ private void OnDetachedFromTarget(object sender, DetachedFromTargetEventArgs e)
125125
private void OnAttachedToTarget(object sender, AttachedToTargetEventArgs e)
126126
{
127127
var targetInfo = e.TargetInfo == null ? null : new TargetInfo
128-
{
129-
BrowserContextId = e.TargetInfo.BrowserContextId,
130-
IsAttached = e.TargetInfo.Attached,
131-
OpenerId = e.TargetInfo.OpenerId,
132-
TargetId = e.TargetInfo.TargetId,
133-
Title = e.TargetInfo.Title,
134-
Type = e.TargetInfo.Type,
135-
Url = e.TargetInfo.Url
128+
{
129+
BrowserContextId = e.TargetInfo.BrowserContextId,
130+
IsAttached = e.TargetInfo.Attached,
131+
OpenerId = e.TargetInfo.OpenerId,
132+
TargetId = e.TargetInfo.TargetId,
133+
Title = e.TargetInfo.Title,
134+
Type = e.TargetInfo.Type,
135+
Url = e.TargetInfo.Url
136136
};
137137

138138
this.OnTargetAttached(new TargetAttachedEventArgs

dotnet/src/webdriver/DevTools/v85/V85Target.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ private void OnDetachedFromTarget(object sender, DetachedFromTargetEventArgs e)
118118
}
119119

120120
private void OnAttachedToTarget(object sender, AttachedToTargetEventArgs e)
121-
{
121+
{
122122
var targetInfo = e.TargetInfo == null ? null : new TargetInfo
123-
{
124-
BrowserContextId = e.TargetInfo.BrowserContextId,
125-
IsAttached = e.TargetInfo.Attached,
126-
OpenerId = e.TargetInfo.OpenerId,
127-
TargetId = e.TargetInfo.TargetId,
128-
Title = e.TargetInfo.Title,
129-
Type = e.TargetInfo.Type,
130-
Url = e.TargetInfo.Url
123+
{
124+
BrowserContextId = e.TargetInfo.BrowserContextId,
125+
IsAttached = e.TargetInfo.Attached,
126+
OpenerId = e.TargetInfo.OpenerId,
127+
TargetId = e.TargetInfo.TargetId,
128+
Title = e.TargetInfo.Title,
129+
Type = e.TargetInfo.Type,
130+
Url = e.TargetInfo.Url
131131
};
132132

133133
this.OnTargetAttached(new TargetAttachedEventArgs

dotnet/src/webdriver/Internal/FileUtilities.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,18 @@ public static string GetCurrentDirectory()
188188

189189
string currentDirectory = location!;
190190

191+
#if !NET8_0_OR_GREATER
191192
// If we're shadow copying, get the directory from the codebase instead
192193
if (AppDomain.CurrentDomain.ShadowCopyFiles)
193194
{
194-
Uri uri = new Uri(executingAssembly.CodeBase);
195-
currentDirectory = Path.GetDirectoryName(uri.LocalPath)!;
195+
var codeBase = executingAssembly.CodeBase;
196+
197+
if (codeBase is not null)
198+
{
199+
currentDirectory = Path.GetDirectoryName(codeBase);
200+
}
196201
}
202+
#endif
197203

198204
return currentDirectory;
199205
}

dotnet/src/webdriver/PrintOptions.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,30 @@ public class PageSize
259259
private double height = DefaultPageHeight;
260260
private double width = DefaultPageWidth;
261261

262+
/// <summary>
263+
/// Represents the A4 paper size.
264+
/// Width: 21.0 cm, Height: 29.7 cm
265+
/// </summary>
266+
public static PageSize A4 => new PageSize { Width = 21.0, Height = 29.7 }; // cm
267+
268+
/// <summary>
269+
/// Represents the Legal paper size.
270+
/// Width: 21.59 cm, Height: 35.56 cm
271+
/// </summary>
272+
public static PageSize Legal => new PageSize { Width = 21.59, Height = 35.56 }; // cm
273+
274+
/// <summary>
275+
/// Represents the Letter paper size.
276+
/// Width: 21.59 cm, Height: 27.94 cm
277+
/// </summary>
278+
public static PageSize Letter => new PageSize { Width = 21.59, Height = 27.94 }; // cm
279+
280+
/// <summary>
281+
/// Represents the Tabloid paper size.
282+
/// Width: 27.94 cm, Height: 43.18 cm
283+
/// </summary>
284+
public static PageSize Tabloid => new PageSize { Width = 27.94, Height = 43.18 }; // cm
285+
262286
/// <summary>
263287
/// Gets or sets the height of each page in centimeters.
264288
/// </summary>

dotnet/test/common/PrintTest.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,40 @@ public void MarginsCannotHaveNegativeValues()
122122
Assert.That(() => new PrintOptions.Margins { Left = -1 }, Throws.TypeOf<ArgumentOutOfRangeException>());
123123
Assert.That(() => new PrintOptions.Margins { Right = -1 }, Throws.TypeOf<ArgumentOutOfRangeException>());
124124
}
125+
126+
[Test]
127+
public void CanSetPredefinedPageSizes()
128+
{
129+
var options = new PrintOptions();
130+
131+
options.PageDimensions = PrintOptions.PageSize.A4;
132+
Assert.That(options.PageDimensions.Width, Is.EqualTo(PrintOptions.PageSize.A4.Width));
133+
Assert.That(options.PageDimensions.Height, Is.EqualTo(PrintOptions.PageSize.A4.Height));
134+
135+
options.PageDimensions = PrintOptions.PageSize.Legal;
136+
Assert.That(options.PageDimensions.Width, Is.EqualTo(PrintOptions.PageSize.Legal.Width));
137+
Assert.That(options.PageDimensions.Height, Is.EqualTo(PrintOptions.PageSize.Legal.Height));
138+
139+
options.PageDimensions = PrintOptions.PageSize.Letter;
140+
Assert.That(options.PageDimensions.Width, Is.EqualTo(PrintOptions.PageSize.Letter.Width));
141+
Assert.That(options.PageDimensions.Height, Is.EqualTo(PrintOptions.PageSize.Letter.Height));
142+
143+
options.PageDimensions = PrintOptions.PageSize.Tabloid;
144+
Assert.That(options.PageDimensions.Width, Is.EqualTo(PrintOptions.PageSize.Tabloid.Width));
145+
Assert.That(options.PageDimensions.Height, Is.EqualTo(PrintOptions.PageSize.Tabloid.Height));
146+
}
147+
148+
[Test]
149+
public void CanSetCustomPageSize()
150+
{
151+
var options = new PrintOptions();
152+
var customPageSize = new PrintOptions.PageSize { Width = 25.0, Height = 30.0 };
153+
154+
options.PageDimensions = customPageSize;
155+
156+
Assert.That(options.PageDimensions.Width, Is.EqualTo(25.0));
157+
Assert.That(options.PageDimensions.Height, Is.EqualTo(30.0));
158+
}
159+
125160
}
126161
}

dotnet/test/common/RelativeLocatorTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void ExerciseNearLocatorWithXpath()
140140
// 5-8. Diagonally close (pythagoras sorting, with top row first
141141
// because of DOM insertion order)
142142
var values = seen.Select(element => element.GetDomAttribute("id"));
143-
Assert.That(values, Is.EquivalentTo(new List<string> { "top", "bottom", "left", "right", "topLeft", "topRight", "bottomLeft", "bottomRight" }));
143+
Assert.That(values, Is.EquivalentTo(new List<string> { "top", "bottom", "left", "right", "topLeft", "topRight", "bottomLeft", "bottomRight" }));
144144
}
145145

146146
[Test]
@@ -160,7 +160,7 @@ public void ExerciseNearLocatorWithCssSelector()
160160
// 5-8. Diagonally close (pythagoras sorting, with top row first
161161
// because of DOM insertion order)
162162
var values = seen.Select(element => element.GetDomAttribute("id"));
163-
Assert.That(values, Is.EquivalentTo(new List<string> { "top", "bottom", "left", "right", "topLeft", "topRight", "bottomLeft", "bottomRight" }));
163+
Assert.That(values, Is.EquivalentTo(new List<string> { "top", "bottom", "left", "right", "topLeft", "topRight", "bottomLeft", "bottomRight" }));
164164
}
165165

166166
[Test]

0 commit comments

Comments
 (0)