-
Notifications
You must be signed in to change notification settings - Fork 0
FindElement.cs
Avrigeanu Laurian edited this page Apr 11, 2023
·
2 revisions
Finds the first element in the current page that matches the specified CSS selector.
-
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 isfalse
. -
retries
: An optional integer parameter indicating the number of times to retry the search in case of a failure. Default value is3
.
- An
IElementHandle
representing the first element that matches the specified selector.
-
PlaywrightException
: If the Playwright library is unable to find the element.
This method searches for the element in all of the pages in the _context.Pages
collection in reverse order. If lockToLastPage
is true
, it searches only the last page in the collection. If the search fails, it retries the specified number of times, waiting for the page to load between retries. If the element is found, it logs a warning message and returns the element. If the element is not found, it logs an error message and returns null
.