0

I am trying to extract the text contained in a table with class name "infoBoxContents". However, there are multiple tables with this class name, and I am trying to extract text from the third table with this class name. I have tried the following code

String actual = browser.findElement(By.className("infoBoxContents")).getText();

which is naturally returning the text for the first table with the above-mentioned class name. I have done a lot of research on how to reference the particular element of an array but I have not found anything.

How can I correctly access the text within the third table containing that class name?

1 Answer 1

1

You're only looking for one element. This should fix the issue.

String actual = browser.findElements(By.className("infoBoxContents")).get(2).getText();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.