@@ -396,16 +396,26 @@ This behavior is best illustrated with examples::
396396Links
397397~~~~~
398398
399- To find a link by name (or a clickable image by its ``alt `` attribute), use
400- the ``selectLink() `` method on an existing crawler. This returns a ``Crawler ``
401- instance with just the selected link(s). Calling ``link() `` gives you a special
402- :class: `Symfony\\ Component\\ DomCrawler\\ Link ` object::
403-
404- $linksCrawler = $crawler->selectLink('Go elsewhere...');
405- $link = $linksCrawler->link();
406-
407- // or do this all at once
408- $link = $crawler->selectLink('Go elsewhere...')->link();
399+ Use the ``filter() `` method to find links by their ``id `` or ``class ``
400+ attributes and use the ``selectLink() `` method to find links by their content
401+ (it also finds clickable images with that content in its ``alt `` attribute).
402+
403+ Both methods return a ``Crawler `` instance with just the selected link. Use the
404+ ``link() `` method to get the :class: `Symfony\\ Component\\ DomCrawler\\ Link ` object
405+ that represents the link::
406+
407+ // first, select the link by id, class or content...
408+ $linkCrawler = $crawler->filter('#sign-up');
409+ $linkCrawler = $crawler->filter('.user-profile');
410+ $linkCrawler = $crawler->selectLink('Log in');
411+
412+ // ...then, get the Link object:
413+ $link = $linkCrawler->link();
414+
415+ // or do all this at once:
416+ $link = $crawler->filter('#sign-up')->link();
417+ $link = $crawler->filter('.user-profile')->link();
418+ $link = $crawler->selectLink('Log in')->link();
409419
410420The :class: `Symfony\\ Component\\ DomCrawler\\ Link ` object has several useful
411421methods to get more information about the selected link itself::
0 commit comments