更改Locator取值以参数判断的方式
This commit is contained in:
parent
0dcb9f8c6e
commit
384c9334e2
|
|
@ -12,6 +12,8 @@ public class ElementActionArgs
|
|||
|
||||
public string? PressKey { get; set; }
|
||||
|
||||
public bool? IsFirst { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Wait time in seconds
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,12 @@ public partial class PlaywrightWebDriver
|
|||
return;
|
||||
}
|
||||
|
||||
ILocator locator = page.Locator(result.Selector).First;// 匹配到多个时取第一个,否则当await locator.ClickAsync();匹配到多个就会抛异常。
|
||||
ILocator locator = page.Locator(result.Selector);
|
||||
if (action.IsFirst == true)
|
||||
{
|
||||
locator = page.Locator(result.Selector).First;// 匹配到多个时取第一个,否则当await locator.ClickAsync();匹配到多个就会抛异常。
|
||||
}
|
||||
|
||||
var count = await locator.CountAsync();
|
||||
if (count == 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue