title: How to find the table row number using Selenium Webdriver Java
body: <p>I have a table with multiple rows and multiple columns. </p>
  
  <p>The HTML codes look like this:</p>
  
  <pre><code>&lt;!-- language: lang-html --&gt;
      &lt;div id="ScheduleTable-01" class="widget Scheduletable suppress-errors Schedule-grid" data-widget="ScheduleTable"&gt;
      &lt;div class="grid-wrapper"&gt;
      &lt;table class="nostyles weekmode hourstype fullmonth" style="width: 100%;"&gt;
      &lt;thead&gt;
      &lt;tbody&gt;
      &lt;tr id="20631697" class="Schedule-row row0 20631697 key_AuthoriserId-1077_JobId-402704200_TaskId-CON_TsCode-35" data-row-index="0" data-job="402121200,Job XXX"&gt;
      &lt;tr id="-499545938" class="Schedule-row row1 -499545938 key_AuthoriserId-1077_JobId-A01200131S_TaskId-CON_TsCode-35" data-row-index="1" data-job="A01763431 Job YYY"&gt;
      &lt;tr id="-985929934" class="Schedule-row row2 -985929934 key_AuthoriserId-1277_JobId-I02010171S_TaskId-INT_TsCode-30" data-row-index="2" data-job="I02872371 S,Job ZZZ"&gt;
  </code></pre>
  
  <p>Because it is a dynamic webpage, every time the page loads, <em>Job YYY</em> will be placed in different row index. Thus, I want to know in which row of the table <em>Job YYY</em> is located. 
  I can see that each row is marked with <code>data-row-index</code>,  that is what I want to get. </p>
  
  <p>I am thinking about this Selenium code </p>
  
  <pre><code>&lt;!-- language: lang-java --&gt;
  WebElement mainTable = driver.findElement(By.id("ScheduleTable-01"));
  //I am not sure about this part below; findElements By ???
  List&lt;WebElement&gt; tableRows = mainTable.findElements(By.tagName("tr"));
  </code></pre>
  
  <p>In this case, how can I find the row number? Thanks.   </p>