Welcome to the Treehouse Community
Looking to learn something new?
How can I extract text from: <div class="listview-total">Total: 4 Reservation(s)</div>
How can I extract text using Selenium from the following:
<div class="listview-total">Total: 4 Reservation(s)</div>
I want an object that contains the string "Total: 4 Reservation(s)"
Greg Kaleka39,018 Points
id, you can't use
document.getElementById() - you have to instead use
document.getElementByClassName(), which returns a array. If you've only got the one element on your page with that class, then you can simply take the first element in that array, and use the attribute
textContent to get the text between the tags.
var theDiv = document.getElementsByClassName("listview-total"); var text = theDiv.textContent
Let me know if this isn't what you're after!