Skip to content

WaitElementVisible.cs

Avrigeanu Laurian edited this page Apr 11, 2023 · 1 revision

WaitElementVisible(string selector, bool lockToLastPage = false, int retries = 15) Method

Waits for the first element in the current page that matches the specified selector to become visible, and returns it.

Parameters

  • selector : A selector that identifies the element to be found.
  • lockToLastPage : An optional boolean parameter indicating whether to search only the last page in the _context.Pages collection. Default value is false.
  • retries : An optional integer parameter indicating the number of times to retry the search in case of a failure. Default value is 15.

Returns

  • An IElementHandle representing the first visible element that matches the specified selector.

Exceptions

  • PlaywrightException: If the Playwright library is unable to find the element.

Remarks

This method first calls the FindElement() method with the specified selector and lockToLastPage parameter, and waits for the element to appear. If the element is not found, it retries the search the specified number of times, waiting for the element to appear each time. Once the element is found, it waits for it to become visible. If the element is visible, it logs an information message with the selector, and returns the element. If the element is not visible after the specified number of retries, a PlaywrightException is thrown. If the element is not found, a PlaywrightException is thrown.

Clone this wiki locally