question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to select by attribute/class

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version:1.19.0
  • Platform / OS version:MacOS
  • Node.js version:v10.4.1

Trying to select this

<a class="KxR2cf-za" title="Click Here">Click Here</a>

and using this code

const elementHandle = await page.$('a[class="KxR2cf-za"]');
console.log(elementHandle);

however console is printing null even though chromium shows the node in UI. What am i doing wrong ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
carefulcomputercommented, Sep 6, 2019

@vsemozhetbyt … that was it !! I was looking for element in main frame, but element was in an iframe. after fetching right iframe, it worked perfectly. Thank you !

0reactions
vsemozhetbytcommented, Sep 6, 2019

@qwertangel Can it be that the element is inside an iframe?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to select by attribute/class · Issue #4909 - GitHub
Platform / OS version:MacOS; Node.js version:v10.4.1. Trying to select this. <a class="KxR2cf-za" title="Click ...
Read more >
CSS attribute selectors not selecting - Stack Overflow
Possible solutions would be to re-order the class attribute values to ensure that *-window appears at the end. Alternatively, you could use the...
Read more >
Attribute selectors - CSS: Cascading Style Sheets | MDN
The CSS attribute selector matches elements based on the presence or value of a given attribute.
Read more >
How To Select HTML Elements Using ID, Class, and Attribute ...
To begin, open your styles. css file in the text editor. In the HTML there is a link that goes to the website...
Read more >
Select by Attributes misses records? - Esri Community
I'm running Select By Attributes on a feature class to select shape area less than 300, but only a fraction of the records...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found