title: In Selenium, after matching certain condition, click on the first delete button
body: <p>I am trying to test adding and deleting blog post using selenium. We already have a few blog entries in our system which I do NOT want to delete, only the one which I created. So in the example below, you'll see "My blog"  followed by name="ctl00$ctl00$OuterTaskRegion$TaskRegion$TaskRegion$PostList1$theposts$ctl02$DeleteButton" value="Delete" 
  and then another blog item followed by delete. I want to click the delete button after "My Blog"</p>
  
  <pre><code>   &lt;tr&gt;
              &lt;td class="CommonListCellLeftMost"&gt;
                  &lt;span&gt;&lt;a href/2015/05/15/my-blog.aspx"&gt;
                      My blog &lt;/a&gt;&lt;/span&gt;
                  &lt;div style="font-size:.8em; color:#959595"&gt;
                  Drafted by
                 QATest1
                  on
                  May 15, 2015
                  at
                  2:32 PM
                  &lt;/div&gt;
              &lt;/td&gt;
              &lt;td class="CommonListCell PostViewsCell"&gt;
                      &lt;a href="/cs/controlpanel/blogs/views.aspx? WeblogID=103&amp;WeblogPostID=131221"&gt;
                      0&lt;/a&gt;
              &lt;/td&gt;
              &lt;td class="CommonListCell PostCommentsCell"&gt;
                  &lt;a href="/cs/controlpanel/blogs/comments.aspx?WeblogID=103&amp;WeblogPostID=131221"&gt;
                      0&lt;/a&gt;
              &lt;/td&gt;
              &lt;td class="CommonListCell PostImageStatusCell"&gt;
                  &lt;img src="/cs/unpublished.gif"
                      title="Unpublished"/&gt;
              &lt;/td&gt;
              &lt;td  class="CommonListCell" nowrap="nowrap"&gt;
                  &lt;input type="button"      onclick="window.location='/posteditor.aspx"value="Edit" /&gt;
                  &lt;input type="submit"     name="ctl00$ctl00$OuterTaskRegion$TaskRegion$TaskRegion$PostList1$theposts$ctl02     $DeleteButton" value="Delete" onclick="return confirm(&amp;#39;Delete? \n(this     action cannot be undone)&amp;#39;);"       id="ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_PostList1_theposts_ctl02_D        eleteButton" /&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
  
          &lt;tr class="AltListRow"&gt;
              &lt;td class="CommonListCellLeftMost"&gt;
                  &lt;span&gt;&lt;a href="/cs/community/b/blog/archive/2015/05/12/not-           mine.aspx"&gt;
                     not mine&lt;/a&gt;&lt;/span&gt;
                  &lt;div style="font-size:.8em; color:#959595"&gt;
                  Published by
                  QAguestB
                  on
                  May 12, 2015
                  at
                  4:05 PM
                  &lt;/div&gt;
              &lt;/td&gt;
              &lt;td class="CommonListCell PostViewsCell"&gt;
                  &lt;a href="/cs/controlpanel/blogs/views.aspx?   WeblogID=103&amp;WeblogPostID=131216"&gt;
                      8&lt;/a&gt;
              &lt;/td&gt;
              &lt;td class="CommonListCell PostCommentsCell"&gt;
                  &lt;a href="/cs/controlpanel/blogs/comments.aspx?   WeblogID=103&amp;WeblogPostID=131216"&gt;
                      0&lt;/a&gt;
              &lt;/td&gt;
              &lt;td class="CommonListCell PostImageStatusCell"&gt;
                  &lt;img src="/cs/controlpanel/images/comment/published.gif"
                      title="Published"/&gt;
              &lt;/td&gt;
              &lt;td  class="CommonListCell"&gt;
                  &lt;input type="button"    onclick="window.location='/cs/controlpanel/blogs/posteditor.aspx?    SelectedNavItem=Posts&amp;WeblogID=103&amp;WeblogPostID=131216';" value="Edit" /&gt;
                  &lt;input type="submit"     name="ctl00$ctl00$OuterTaskRegion$TaskRegion$TaskRegion$PostList1$theposts$ctl03         $DeleteButton" value="Delete" onclick="return confirm(&amp;#39;Are you sure    you want to delete this post? \n(this action cannot be undone)&amp;#39;);"    id="ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_PostList1_theposts_ctl03_D       eleteButton" /&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
  </code></pre>