How can i click on the link, which contains a text inside the span
See original GitHub issueI am trying to click on the link, which contains a text inside the span
Code i tried
page
.waitForSelector('span[text=]')
.then(() => page.click('span[text=dummy]'));
DOM
<a class="nt-card__headline" href="/test" tabindex="0" ">
<span aria-hidden="true">
Some
<span class="white-space-pre"> </span>
dummy
<span class="white-space-pre"> </span>
text to match
</span>
<span class="visually-hidden">Some dummy text to match</span>
</a>
Any suggestion how how can i do this?
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
How to click a link that has been found using a span defined ...
findElement(By.xpath("//a[contains(.,'News')]")).click();. This SO post has more details on other path functions: XPath contains(text() ...
Read more >How to find and click a span class element using the text of a ...
I am using the latest version of Selenium in Python. How do I use driver.find_element to find, and then .click() , the checkbox...
Read more >The Content Span element - HTML - MDN Web Docs
The <span> HTML element is a generic inline container for phrasing content, ... This element only includes the global attributes.
Read more >Links - Usability & Web Accessibility - Yale University
When creating links, developers should use the <a> tag. The <a> tag has important accessibility features built in by default. It is keyboard...
Read more >How to create XPath for the Link which ... - Google Groups
You <span> is not in your <a>, so //li/div/h2/a/span[contains(text(), 'YES')] won't match anything. Assuming the HTML you posted is correct, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

If I understand correctly, you need to find a link by its text content to click on. If so, these are at least two ways:
We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!