使用剧作家有没有一种方法可以在特定框架内等待forselectorAsync?
我写了几种扩展方法来简化这样的常见测试动作。
public static async Task WaitForElementToBeShown(this IPage page, string selector, int maxWaitInSeconds = 30, bool tolerateMultiples = true) {
await page.WaitForSelectorAsync(selector, new PageWaitForSelectorOptions { State = WaitForSelectorState.Visible, Strict = !tolerateMultiples, Timeout = maxWaitInSeconds * 1000 });
}
不幸的是,如果元素在框架中,这次是算出的。
有没有办法在特定框架内等待元素?
有没有办法等待元素不管其框架如何?
我知道我可以将以下内容包裹在循环中,然后等待它是真实的,但我希望剧作家已经实施了一些东西。
await _page.FrameLocator("frame locator").Locator("some selector").IsVisibleAsync();
我也认为,如果定位器不是唯一的话,这将引发例外。有没有办法使这条线可以容忍像WaitforselectorAsync方法一样?
I wrote a couple of extension methods to simplify common test actions like this.
public static async Task WaitForElementToBeShown(this IPage page, string selector, int maxWaitInSeconds = 30, bool tolerateMultiples = true) {
await page.WaitForSelectorAsync(selector, new PageWaitForSelectorOptions { State = WaitForSelectorState.Visible, Strict = !tolerateMultiples, Timeout = maxWaitInSeconds * 1000 });
}
Unfortunately this times out if the element is in a frame.
Is there a way to wait for an element inside a specific frame?
Is there a way to wait for an element to be shown regardless of it's frame?
I know I could wrap the following in a loop and wait for it to be true but I was hoping that playwright had implemented something already.
await _page.FrameLocator("frame locator").Locator("some selector").IsVisibleAsync();
also I think this will throw an exception if the locator isn't unique. Is there a way to make this line tolerate multiples like the WaitForSelectorAsync method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论