【问题标题】:Using Playwright Is there a way to WaitForSelectorAsync inside of a specific frame?使用 Playwright 有没有办法在特定框架内 WaitForSelectorAsync ?
【发布时间】:2022-08-14 21:25:25
【问题描述】:

我写了几个扩展方法来简化像这样的常见测试操作。

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 方法这样的倍数?

    标签: c# automated-tests playwright


    【解决方案1】:

    您可以先检查 iframe 可见,然后检查定位器

    【讨论】:

      猜你喜欢
      • 2021-04-17
      • 2019-09-12
      • 1970-01-01
      • 1970-01-01
      • 2021-12-18
      • 2019-07-27
      • 1970-01-01
      • 1970-01-01
      • 2013-02-28
      相关资源
      最近更新 更多