TestBench select AnchorElement (RouterLink) by text

How can I reference a AnchorElement by text?

For example <a href="#">Link</a> I would like to use somehting like $(AnchorElement.class).text("Link").

You can use the Selenium API to query for the anchor: findElement(By.linkText("Link")).

If you want to wrap it into a test bench element, you can use wrap(AnchorElement.class, findElement(By.linkText("Link"))).

1 Like

Thank you very much @sissbruecker. Wasn’t aware of these helper methods in TestBenchElement.

I think the syntax has changed to:
findElement(By.linkText("Link")).wrap(AnchorElement.class)