修改Locator匹配到多个时取第一个值

This commit is contained in:
AnonymousDotNet 2024-08-21 17:12:32 +08:00
parent ae1faaf2f4
commit 0dcb9f8c6e

View file

@ -11,7 +11,7 @@ public partial class PlaywrightWebDriver
return;
}
ILocator locator = page.Locator(result.Selector);
ILocator locator = page.Locator(result.Selector).First;// 匹配到多个时取第一个否则当await locator.ClickAsync();匹配到多个就会抛异常。
var count = await locator.CountAsync();
if (count == 0)
{