Skip to content

Commit 858354b

Browse files
authored
chore: roll Playwright to 1.19.0 (#2008)
1 parent 82710bc commit 858354b

12 files changed

+112
-8
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
| | Linux | macOS | Windows |
55
| :--- | :---: | :---: | :---: |
6-
| Chromium <!-- GEN:chromium-version -->99.0.4837.0<!-- GEN:stop --> ||||
6+
| Chromium <!-- GEN:chromium-version -->100.0.4863.0<!-- GEN:stop --> ||||
77
| WebKit <!-- GEN:webkit-version -->15.4<!-- GEN:stop --> ||||
88
| Firefox <!-- GEN:firefox-version -->96.0.1<!-- GEN:stop --> ||||
99

src/Common/Version.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
3-
<AssemblyVersion>1.18.0</AssemblyVersion>
3+
<AssemblyVersion>1.19.0</AssemblyVersion>
44
<PackageVersion>$(AssemblyVersion)</PackageVersion>
5-
<DriverVersion>1.19.0-alpha-jan-31-2022</DriverVersion>
5+
<DriverVersion>1.19.0</DriverVersion>
66
<ReleaseVersion>$(AssemblyVersion)</ReleaseVersion>
77
<FileVersion>$(AssemblyVersion)</FileVersion>
88
<NoDefaultExcludes>true</NoDefaultExcludes>

src/Playwright.Tests/CLITests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ namespace Microsoft.Playwright.Tests
3131
{
3232
public class CLITests : PlaywrightTest
3333
{
34-
TextWriter _originalStdOut = Console.Out;
35-
TextWriter _originalStdError = Console.Error;
34+
readonly TextWriter _originalStdOut = Console.Out;
35+
readonly TextWriter _originalStdError = Console.Error;
3636
StringWriter _cliStdOut;
3737
StringWriter _cliStdError;
3838

src/Playwright.Tests/Locator/LocatorQueryTests.cs

+28
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25+
using System;
2526
using System.Text.RegularExpressions;
2627
using System.Threading.Tasks;
2728
using NUnit.Framework;
@@ -124,5 +125,32 @@ public async Task ShouldFilterByRegexandRegexpFlags()
124125
await Page.SetContentAsync("<div>Hello \"world\"</div><div>Hello world</div>");
125126
StringAssert.Contains(await Page.Locator("div", new() { HasTextRegex = new Regex("hElLo \"wOrld\"", RegexOptions.IgnoreCase) }).InnerTextAsync(), "Hello \"world\"");
126127
}
128+
129+
[PlaywrightTest("locator-query.spec.ts", "should support has:locator")]
130+
public async Task ShouldSupportHasLocator()
131+
{
132+
await Page.SetContentAsync("<div><span>hello</span></div><div><span>world</span></div>");
133+
Assert.AreEqual(1, await Page.Locator("div", new() { Has = Page.Locator("text=world") }).CountAsync());
134+
Assert.AreEqual("<div><span>world</span></div>", await Page.Locator("div", new() { Has = Page.Locator("text=world") }).EvaluateAsync<string>("e => e.outerHTML"));
135+
Assert.AreEqual(1, await Page.Locator("div", new() { Has = Page.Locator("text=hello") }).CountAsync());
136+
Assert.AreEqual("<div><span>hello</span></div>", await Page.Locator("div", new() { Has = Page.Locator("text=hello") }).EvaluateAsync<string>("e => e.outerHTML"));
137+
Assert.AreEqual(2, await Page.Locator("div", new() { Has = Page.Locator("xpath=./span") }).CountAsync());
138+
Assert.AreEqual(1, await Page.Locator("div", new() { Has = Page.Locator("span", new() { HasTextString = "wor" }) }).CountAsync());
139+
Assert.AreEqual("<div><span>world</span></div>", await Page.Locator("div", new() { Has = Page.Locator("span", new() { HasTextString = "wor" }) }).EvaluateAsync<string>("e => e.outerHTML"));
140+
Assert.AreEqual(1, await Page.Locator("div", new() { HasTextString = "wor", Has = Page.Locator("span") }).CountAsync());
141+
}
142+
143+
[PlaywrightTest("locator-query.spec.ts", "should enforce same frame for has:locator'")]
144+
public async Task ShouldEnforceSameFrameForHasLocator()
145+
{
146+
await Page.GotoAsync(Server.Prefix + "/frames/two-frames.html");
147+
var child = Page.Frames[1];
148+
var exception = await PlaywrightAssert.ThrowsAsync<ArgumentException>(() =>
149+
{
150+
Page.Locator("div", new() { Has = child.Locator("span") });
151+
return Task.CompletedTask;
152+
});
153+
Assert.AreEqual(exception.Message, "Inner \"has\" locator must belong to the same frame.");
154+
}
127155
}
128156
}

src/Playwright/API/Generated/Options/FrameLocatorLocatorOptions.cs

+15
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,25 @@ public FrameLocatorLocatorOptions() { }
4646
public FrameLocatorLocatorOptions(FrameLocatorLocatorOptions clone)
4747
{
4848
if (clone == null) return;
49+
Has = clone.Has;
4950
HasTextString = clone.HasTextString;
5051
HasTextRegex = clone.HasTextRegex;
5152
}
5253

54+
/// <summary>
55+
/// <para>
56+
/// Matches elements containing an element that matches an inner locator. Inner locator
57+
/// is queried against the outer one. For example, <c>article</c> that has <c>text=Playwright</c>
58+
/// matches <c>&lt;article&gt;&lt;div&gt;Playwright&lt;/div&gt;&lt;/article&gt;</c>.
59+
/// </para>
60+
/// <para>
61+
/// Note that outer and inner locators must belong to the same frame. Inner locator
62+
/// must not contain <see cref="IFrameLocator"/>s.
63+
/// </para>
64+
/// </summary>
65+
[JsonPropertyName("has")]
66+
public ILocator? Has { get; set; }
67+
5368
/// <summary>
5469
/// <para>
5570
/// Matches elements containing specified text somewhere inside, possibly in a child

src/Playwright/API/Generated/Options/FrameLocatorOptions.cs

+15
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,25 @@ public FrameLocatorOptions() { }
4646
public FrameLocatorOptions(FrameLocatorOptions clone)
4747
{
4848
if (clone == null) return;
49+
Has = clone.Has;
4950
HasTextString = clone.HasTextString;
5051
HasTextRegex = clone.HasTextRegex;
5152
}
5253

54+
/// <summary>
55+
/// <para>
56+
/// Matches elements containing an element that matches an inner locator. Inner locator
57+
/// is queried against the outer one. For example, <c>article</c> that has <c>text=Playwright</c>
58+
/// matches <c>&lt;article&gt;&lt;div&gt;Playwright&lt;/div&gt;&lt;/article&gt;</c>.
59+
/// </para>
60+
/// <para>
61+
/// Note that outer and inner locators must belong to the same frame. Inner locator
62+
/// must not contain <see cref="IFrameLocator"/>s.
63+
/// </para>
64+
/// </summary>
65+
[JsonPropertyName("has")]
66+
public ILocator? Has { get; set; }
67+
5368
/// <summary>
5469
/// <para>
5570
/// Matches elements containing specified text somewhere inside, possibly in a child

src/Playwright/API/Generated/Options/LocatorLocatorOptions.cs

+15
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,25 @@ public LocatorLocatorOptions() { }
4646
public LocatorLocatorOptions(LocatorLocatorOptions clone)
4747
{
4848
if (clone == null) return;
49+
Has = clone.Has;
4950
HasTextString = clone.HasTextString;
5051
HasTextRegex = clone.HasTextRegex;
5152
}
5253

54+
/// <summary>
55+
/// <para>
56+
/// Matches elements containing an element that matches an inner locator. Inner locator
57+
/// is queried against the outer one. For example, <c>article</c> that has <c>text=Playwright</c>
58+
/// matches <c>&lt;article&gt;&lt;div&gt;Playwright&lt;/div&gt;&lt;/article&gt;</c>.
59+
/// </para>
60+
/// <para>
61+
/// Note that outer and inner locators must belong to the same frame. Inner locator
62+
/// must not contain <see cref="IFrameLocator"/>s.
63+
/// </para>
64+
/// </summary>
65+
[JsonPropertyName("has")]
66+
public ILocator? Has { get; set; }
67+
5368
/// <summary>
5469
/// <para>
5570
/// Matches elements containing specified text somewhere inside, possibly in a child

src/Playwright/API/Generated/Options/PageLocatorOptions.cs

+15
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,25 @@ public PageLocatorOptions() { }
4646
public PageLocatorOptions(PageLocatorOptions clone)
4747
{
4848
if (clone == null) return;
49+
Has = clone.Has;
4950
HasTextString = clone.HasTextString;
5051
HasTextRegex = clone.HasTextRegex;
5152
}
5253

54+
/// <summary>
55+
/// <para>
56+
/// Matches elements containing an element that matches an inner locator. Inner locator
57+
/// is queried against the outer one. For example, <c>article</c> that has <c>text=Playwright</c>
58+
/// matches <c>&lt;article&gt;&lt;div&gt;Playwright&lt;/div&gt;&lt;/article&gt;</c>.
59+
/// </para>
60+
/// <para>
61+
/// Note that outer and inner locators must belong to the same frame. Inner locator
62+
/// must not contain <see cref="IFrameLocator"/>s.
63+
/// </para>
64+
/// </summary>
65+
[JsonPropertyName("has")]
66+
public ILocator? Has { get; set; }
67+
5368
/// <summary>
5469
/// <para>
5570
/// Matches elements containing specified text somewhere inside, possibly in a child

src/Playwright/API/Generated/Options/TracingStartOptions.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ public TracingStartOptions(TracingStartOptions clone)
7171
[JsonPropertyName("screenshots")]
7272
public bool? Screenshots { get; set; }
7373

74-
/// <summary><para>Whether to capture DOM snapshot on every action.</para></summary>
74+
/// <summary>
75+
/// <para>If this option is true tracing will</para>
76+
/// <list type="bullet">
77+
/// <item><description>capture DOM snapshot on every action</description></item>
78+
/// <item><description>record network activity</description></item>
79+
/// </list>
80+
/// </summary>
7581
[JsonPropertyName("snapshots")]
7682
public bool? Snapshots { get; set; }
7783

src/Playwright/Core/Frame.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ public async Task<T> EvalOnSelectorAllAsync<T>(string selector, string script, o
517517
script,
518518
arg: ScriptsHelper.SerializedArgument(arg)).ConfigureAwait(false));
519519

520-
public ILocator Locator(string selector, FrameLocatorOptions options = null) => new Locator(this, selector, new() { HasTextRegex = options?.HasTextRegex, HasTextString = options?.HasTextString });
520+
public ILocator Locator(string selector, FrameLocatorOptions options = null) => new Locator(this, selector, new() { HasTextRegex = options?.HasTextRegex, HasTextString = options?.HasTextString, Has = options?.Has });
521521

522522
public async Task<IElementHandle> QuerySelectorAsync(string selector, FrameQuerySelectorOptions options = null)
523523
=> (await _channel.QuerySelectorAsync(selector, options?.Strict).ConfigureAwait(false))?.Object;

src/Playwright/Core/Locator.cs

+10
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ public Locator(Frame parent, string selector, LocatorLocatorOptions options = nu
5555
{
5656
_selector += $" >> :scope:has-text({options.HasTextString.EscapeWithQuotes("\"")})";
5757
}
58+
59+
if (options?.Has != null)
60+
{
61+
var has = (Locator)options.Has;
62+
if (has._frame != _frame)
63+
{
64+
throw new ArgumentException("Inner \"has\" locator must belong to the same frame.");
65+
}
66+
_selector += " >> has=" + JsonSerializer.Serialize(has._selector);
67+
}
5868
}
5969

6070
public ILocator First => new Locator(_frame, $"{_selector} >> nth=0");

src/Playwright/Core/Page.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ public Task<T> EvalOnSelectorAsync<T>(string selector, string expression, object
474474
=> MainFrame.EvalOnSelectorAsync<T>(selector, expression, arg, new() { Strict = options?.Strict });
475475

476476
public ILocator Locator(string selector, PageLocatorOptions options = default)
477-
=> MainFrame.Locator(selector, new() { HasTextString = options?.HasTextString, HasTextRegex = options?.HasTextRegex });
477+
=> MainFrame.Locator(selector, new() { HasTextString = options?.HasTextString, HasTextRegex = options?.HasTextRegex, Has = options?.Has });
478478

479479
public Task<IElementHandle> QuerySelectorAsync(string selector, PageQuerySelectorOptions options = null)
480480
=> MainFrame.QuerySelectorAsync(selector, new() { Strict = options?.Strict });

0 commit comments

Comments
 (0)