How to get text from a web page – document.getElementsByClassName

I’m trying to get some text from the website.

I tried this, but it doesn’t work, it gives me “undefined”

CurBrowser.GetMainFrame().ExecuteJavaScriptAsync("var elems1 = document.getElementsByClassName('some-text')");
            CurBrowser.GetMainFrame().ExecuteJavaScriptAsync("for(var i = 0; i < elems1.length; i++){var textt = elems1[i].innerText}");
            CurBrowser.GetMainFrame().ExecuteJavaScriptAsync("alert(textt)");

and this is what I am trying to target

<p class="some-text">
        hello World
    </p>

Answer

const elements = document.getElementsByClassName('some-text');

for (const element of elements) {
  console.log(element.innerText);
}
<p class="some-text">
  Text from paragraph 1
</p>

<p class="some-text">
  Text from paragraph 2
</p>