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?