Getting InnerHTML from all a.username

Skip to first unread message

Quinten De Wilde

Feb 23, 2021, 3:57:05 AMFeb 23
to Chrome DevTools

Is there a way that I can extract the following data in **Chrome Devtools Console**.

Currently I do the following in the console of the chrome devtool: 


I get a list with all the `a` tags and I need from all the `a.username` the `InnerHTML` or the `innerText`

    86: a
    87: a.username
    88: a
    89: a
    90: a.username
    91: a
    92: a
    93: a.username
    94: a
    95: a
    96: a.username
    97: a
    98: a
    99: a.username
    [100 … 198]
    100: a
    101: a
    102: a.username
    103: a
    104: a
    105: a.username
    106: a
    107: a
    108: a.username
    109: a
    110: a
    111: a.username

It's unclear for me how to proceed further into getting this. Lots of terminology makes it unclear what the `InnerHTML` is from the `a` tag and how to extract this for all the same `a.username`

    hrefTranslate: ""
    hreflang: ""
    id: ""
    innerHTML: "**Ineedthis**"
    innerText: "**Orthis**"
    inputMode: ""
    isConnected: true
    isContentEditable: false
    lang: ""

Yang Guo

Feb 23, 2021, 4:05:42 AMFeb 23
to Google Chrome Developer Tools
`$x` gives you an array. You probably want to try something like `$x("//a").map(x=>x.innerHTML)`

You received this message because you are subscribed to the Google Groups "Chrome DevTools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit


Feb 23, 2021, 4:07:45 AMFeb 23
to Google Chrome Developer Tools
Not sure this is a Developer Tools related question... Seems a bit like a JavaScript/DOM related question (out of scope).

$x as well as $$ return an array of elements, so you can do whatever you want with this array.
$$("a.username").map(element => element.innerHTML); // will return an array of innerHTML values of a.username.
The XPath equivalent (assuming the class attribute has only username in it, no spaces) is $x("//a[@class = 'username']").map(element => element.innerHTML); but you need to familiarize yourself with XPath a bit (if you have not already) in order to cook up similarly more-complex selectors.



Quinten De Wilde

Feb 23, 2021, 4:12:59 AMFeb 23
to Chrome DevTools
That was the trick! 

Op dinsdag 23 februari 2021 om 10:05:42 UTC+1 schreef Yang Guo:
Reply all
Reply to author
0 new messages