I've been trying to figure this out, and it seems like it should be a simple task, but how can I extract the text from a table displayed in a browser?
When I use the "inspect" tool, the code snippet looks something like this:
<tr role="row">
<th class="component-body-text" colspan="1"role="columnheader">### The Text I want ###</th>
While there is more content in the table, my focus is solely on retrieving that specific piece of text.
Would a method similar to this work:
await driver.findElement(By.className('component-body-text')).getText();
Unfortunately, this approach didn't yield results. Should I consider handling multiple elements within the table instead:
const sample = await driver.findElements(By.className('component-body-text'));
sampleText = sample[0].getText();
I have experimented with both methods, but haven't had success yet.