I am new to selenium and working with xpath. I am using selenium and java to write automated tests for chat messaging web application.
I am looking for a way to take a webElement which contains multiple formatted text strings in HTML and add it to an array. For example, the following message contains three words each have a type of formatting applied to it(Bold, Italics, Underline).
<div class="ms-txt">
<div>
<span style="font-weight: bold;">Test</span>
<span style="font-style: italic;">Message</span>
<span style="text-decoration: underline;">One</span>
</div>
</div>
I would like to take each formatted message add it to array/list using Selenium/java. I would assume the array would look like the following:
0 : <span style="font-weight: bold;">Test</span>
1 : <span style="font-style: italic;">Message</span>
2 : <span style="text-decoration: underline;">One</span>
Some caveats is the message is a single message and this would be its contents. This array/list would be used later to validate the formatted contents of a single message.
I figure I could always take the content of the div and pull the HTML content into a string then perform another operation to take the string put each formatted substring into an array/list. I would rather find a way to pull the HTML substring and add it to an array/list from the get-go.
Any ideas what I could try?