所以我正在从 Selenium .net 转移到 PlayWrightSharp 的过程中,我所做的是获取当前句柄并能够在选项卡之间切换......我无法在 playwrightsharp 中找到一个明确的方法来做到这一点。
示例:硒
public IWebDriver ReturnlastKnownPageSession(IWebDriver _driver)
{
return _driver.SwitchTo().Window(_driver.WindowHandles.Last());
}
PlayWriteSharp:
[PlaywrightTest("browsercontext-basic.spec.ts", "should return all of the pages")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldReturnAllOfThePages()
{
await using var context = await Browser.NewContextAsync();
var page = await context.NewPageAsync();
var second = await context.NewPageAsync();
Assert.Equal(2, context.Pages.Length);
Assert.Contains(page, context.Pages);
Assert.Contains(second, context.Pages);
}
必须有类似于 selenium 的东西才能获取当前浏览器并在一次调用中找到所有页面并能够在选项卡之间切换
有什么想法吗?