title: Selecting table row headers with xpath
body: <p>I am selecting table headers OK but need to use a similar method to return an index for an item in my row headers.</p>
  
  <p>Here is my attempt...</p>
  
  <pre><code>def return_table_index():
          table = driver.find_element_by_css_selector('#main &gt; table:nth-child(6)')
  </code></pre>
  
  <p>Part 1 column index (returns int correctly for 'table_header')</p>
  
  <pre><code>        table_headers = table.find_elements_by_css_selector('tbody &gt; tr:nth-child(1) &gt; th')
          index_of_column = None
          for i in range(len(table_headers)):
              if table_headers[i].text == table_header:
                  index_of_column = i + 1
          print index_of_column
  </code></pre>
  
  <p>Part 2 row index (returns none, I want an int for 'row_header')  </p>
  
  <pre><code>        row_headers = table.find_elements_by_css_selector('tbody &gt; tr:nth-child(1) &gt; th')
          index_of_row = None
          for i in range(len(row_headers)):
              if row_headers[i].text == row_header:
                  index_of_row = i + 1
          print index_of_row
  </code></pre>
  
  <p>How can I update the xpath in part 2 to return the row index of say 3, which would be 4.</p>
  
  <p><a href="http://www.w3schools.com/html/html_tables.asp" rel="nofollow">Here is my sample data</a></p>