title: How to verify dynamic element present in Selenium WebDriver
body: <p>I'm writing scripts in Python using Selenium WebDriver to test a web application.</p>
  
  <p>The web application allows users to ask questions, which are added to a div as they are asked. Each question div has their own "upvote" and "downvote" link/image. The image changes when the "upvote" icon is clicked, from active to inactive, or vice versa. I know that the xpath to this upvote icon is:</p>
  
  <pre><code>"//div[@id='recent-questions-container']/div/div/div/div/div[2]/div/ul/li/a/i"
  </code></pre>
  
  <p>This "i" at the end of the path is a class, and will either be </p>
  
  <pre><code>&lt;i class="fa fa-2x fa-thumbs-o-up"&gt;&lt;/i&gt;
  </code></pre>
  
  <p>or </p>
  
  <pre><code>&lt;i class="fa fa-2x fa-thumbs-up clicked"&gt;&lt;/i&gt;
  </code></pre>
  
  <p>depending on whether or not it is clicked. I want to verify that the correct image is in place upon being clicked. How can I do that? Ideally, I'd like to perform this verification using assertions, a la:</p>
  
  <pre><code>self.assertTrue(self.is_element_present( ... ))
  </code></pre>
  
  <p>Here is the html for what I'm talking about</p>
  
  <pre><code>&lt;div id="recent-questions-container"&gt;
      &lt;div question_id="randomly generated blah" class="q row recent-question animated pulse" data-score="0"&gt;
          &lt;div class="col-xs-12"&gt;
          &lt;div class="question-content"&gt;
              &lt;p&gt;3&lt;/p&gt;
  
  
              &lt;div class="row question-controls"&gt;
                  &lt;div class="owner-view hidden"&gt;
                      ...
                  &lt;div class="student-view"&gt;
                      &lt;div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 question-controls-left"&gt;
                          &lt;ul class="list-inline"&gt;
                              &lt;li&gt;
                                  &lt;a href="#" class="student-view thumbs-up-to-active"&gt;
                                      &lt;i class="fa fa-thumbs-o-up fa-2x"&gt;&lt;/i&gt;&lt;/a&gt;
                              &lt;/li&gt;
                              &lt;li&gt;
                                  &lt;span class="num-votes"&gt;0&lt;/span&gt;
                              &lt;/li&gt;
                              &lt;li class="thumbs-down-li"&gt;
                                  &lt;a href="#" class="student-view thumbs-down-to-active"&gt;
                                      &lt;i class="fa fa-thumbs-o-down fa-2x"&gt;&lt;/i&gt;&lt;/a&gt;
                              &lt;/li&gt;
                          &lt;/ul&gt;
                      &lt;/div&gt;
  
                  &lt;/div&gt;
  
              &lt;/div&gt;
              &lt;hr&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  ... other questions ... 
              &lt;/div&gt;
              &lt;hr&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  
  
              &lt;/div&gt;
  </code></pre>