title: Selenium - how to get element and its subelements text
body: <p>Short version: I can get the chat message (using selenium's By.xpath in java) but I want to include smiles into proper places.</p>
  
  <p>Longer version:
  Hello,
  I've been tackling this interesting issue where I need to parse a chat message from the web browser and recreate it using java and selenium. I got no problem parsing the text of the message but I want to parse it with it's subelements (smile icons) as well. Is there any good approach to this except for manual source code parsing? </p>
  
  <p>Here's a code for a single message that I'm able to access:</p>
  
  <pre><code>&lt;div class="chat_msg chat_msg_caller "&gt;
      &lt;div class="chat_msg_head"&gt;
          &lt;span class="chat_msg_author"&gt;
              SomeAuthor
          &lt;/span&gt;
          &lt;span class="chat_msg_date"&gt;
             SomeDate
          &lt;/span&gt;
      &lt;/div&gt;
      &lt;div class="chat_msg_body message_text"&gt;
          SomeMessageText
          &lt;span class="sml-icon biggrin"&gt;
              &lt;span&gt;
                  :D
              &lt;/span&gt;
          &lt;/span&gt;
          SomeOtherText
          &lt;span class="sml-icon biggrin"&gt;
              &lt;span&gt;
                  :D
              &lt;/span&gt;
          &lt;/span&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here's an example of how I'm getting the chat message text:</p>
  
  <p><code>
  String msgTxt = we.findElement(By.xpath("//div[@id='messages_body']/div[" + (i + 1) + "]/div[@class='chat_msg_body message_text']")).getText();
  </code></p>
  
  <p>My result: <strong>SomeMessageText SomeOtherText</strong>
  The result I want: <strong>SomeMessageText :D SomeOtherText :D</strong></p>
  
  <p>CSS files:</p>
  
  <pre><code>http://badoocdn.com/v2/-/-/css/base-ltr.268.css
  http://badoocdn.com/v2/-/-/css/page.chat-ltr.22.css
  http://badoocdn.com/v2/-/-/css/popup.messenger-ltr.230.css
  </code></pre>
  
  <p>Structure:</p>
  
  <pre><code>&lt;div id="messages_body"&gt;
     &lt;div id="pager" class="pages"&gt; … &lt;/div&gt;
     &lt;div class="chat_msg chat_msg_caller "&gt;
         &lt;div class="chat_msg_head"&gt;
            &lt;span class="chat_msg_author"&gt; … &lt;/span&gt;
            &lt;span class="chat_msg_date"&gt; … &lt;/span&gt;
         &lt;/div&gt;
         &lt;div class="chat_msg_body message_text"&gt; … &lt;/div&gt;
     &lt;/div&gt;
     &lt;div class="me chat_msg chat_msg_owner "&gt; … &lt;/div&gt;
     &lt;div class="chat_msg chat_msg_caller "&gt; … &lt;/div&gt;
     &lt;div class="me chat_msg chat_msg_owner "&gt; … &lt;/div&gt;
     &lt;div class="chat_msg chat_msg_caller "&gt; … &lt;/div&gt;
     &lt;div class="chat_msg chat_msg_caller "&gt; … &lt;/div&gt;
     &lt;div class="chat_msg chat_msg_caller "&gt; … &lt;/div&gt;
     ...
  </code></pre>