Interface TextFinder
-
Method Summary
Modifier and TypeMethodDescriptionbrowser()
Returns theBrowser
instance of this text finder.void
find
(String text, FindOptions options, Consumer<FindResult> consumer) Performs search of the giventext
with the givenoptions
, highlights all matches and selects the first or the last (depending on the givenFindOptions.isSearchBackward()
flag) match on the currently loaded web page.void
find
(String text, Consumer<FindResult> consumer) Performs search of the giventext
, highlights all matches and selects the first match on the currently loaded web page.void
Stops finding and clears the highlighting of the found matches.void
Stops finding and keeps the currently highlighted match selected.
-
Method Details
-
browser
Browser browser()Returns theBrowser
instance of this text finder.- Since:
- 7.28
-
find
Performs search of the giventext
, highlights all matches and selects the first match on the currently loaded web page.Subsequent calls of this method with the same
text
select the next match.If this method is invoked after
stopFindingAndKeepSelection()
then the search will start from the last selected match, and if afterstopFindingAndClearSelection()
then the search will start from the first match.If the search is still in progress, but the page content is already changed, then the search result will be displayed for the new content of the page (different number of matches, and the next selected match).
The search is performed only through a visible content on the loaded web page. If some text is presented on the web page, but due to CSS rules it is not visible, the text finder will not check this content during search. Also, it does not find text on the web pages with an empty size, so make sure that the size of the browser instance where the text search is performed isn't empty.
- Parameters:
text
- a text to searchconsumer
- a consumer object which allows obtaining the search result- Throws:
IllegalArgumentException
- whentext
is empty or blankObjectClosedException
- when the browser is closed
-
find
Performs search of the giventext
with the givenoptions
, highlights all matches and selects the first or the last (depending on the givenFindOptions.isSearchBackward()
flag) match on the currently loaded web page.Subsequent calls of this method with the same
text
select the next or the previous match depending on the givenFindOptions.isSearchBackward()
flag.If this method is invoked after
stopFindingAndKeepSelection()
then the search will start from the last selected match, and if afterstopFindingAndClearSelection()
then the search will start from the first or the last match depending on the givenFindOptions.isSearchBackward()
flag.If the search is still in progress, but the page content is already changed, then the search result will be displayed for the new content of the page (different number of matches, and the next or the previous selected match).
The search is performed only through a visible content on the loaded web page. If some text is presented on the web page, but due to CSS rules it is not visible, the text finder will not check this content during search. Also, it does not find text on the web pages with an empty size, so make sure that the size of the browser instance where the text search is performed isn't empty.
- Parameters:
text
- a text to searchoptions
- the parameters such as direction and match caseconsumer
- a consumer object which allows obtaining the search result- Throws:
IllegalArgumentException
- whentext
is emptyObjectClosedException
- when the browser is closed
-
stopFindingAndKeepSelection
void stopFindingAndKeepSelection()Stops finding and keeps the currently highlighted match selected.- Throws:
ObjectClosedException
- when the browser is closed
-
stopFindingAndClearSelection
void stopFindingAndClearSelection()Stops finding and clears the highlighting of the found matches.- Throws:
ObjectClosedException
- when the browser is closed
-