title: how to loop through a table in selenium?
body: <p>I am new to selenium and I have this question where I need to loop through a table and get the values in that table   </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table&gt;
    &lt;tr&gt;
      &lt;td style="width:5px"&gt;
      &lt;/td&gt;
      &lt;td&gt;
        &lt;table class="reportTable" id="Allocations"&gt;
          &lt;tbody&gt;
            &lt;tr class="table_header"&gt;
              &lt;td style="width:5px;"&gt;
                &lt;img class="HideImage" src="Images/minus.gif" alt="Hide Details"&gt;
              &lt;/td&gt;
              &lt;td style="width:33%"&gt;
                Channel of Trade&lt;/td&gt;
              &lt;td style="width:33%"&gt;
                PILOT TRAVEL CENTE-122194-W/S - UNB Contract&lt;/td&gt;
              &lt;td style="width:33%"&gt;
                &lt;span id="TruckLoading_10142602_Info" style="COLOR: white;text-decoration:underline;cursor:pointer"&gt;
  Trucks loading - 0&lt;/span&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td style="width:5px;"&gt;
              &lt;/td&gt;
              &lt;td colspan="3"&gt;
                &lt;table rules="rows" class="reportTable" font-family="Tahoma" pagerstyle-visible="False" id="TerminalGrid" border="1"&gt;
                  &lt;tbody&gt;
                    &lt;tr class="productlabel2" align="left"&gt;
                      &lt;td scope="col" style="width:5px;"&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                        Product Details&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr class="hdr2"&gt;
                      &lt;td scope="col" style="width:5px;"&gt;
                      &lt;/td&gt;
                      &lt;td scope="col"&gt;
                        Fuel Type&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr class="FuelTypeHeader"&gt;
                      &lt;td style="width:5px;border:none" onclick="ShowHideDetails(this)"&gt;
                        &lt;img class="HideImage" src="Images/minus.gif" alt="Hide Details" id="Fuel_Img"&gt;
                      &lt;/td&gt;
                      &lt;td style="border-left:none;border-right:none; padding-left:3px"&gt;
                        &lt;table id="C_V" style="width:100%;border-collapse:collapse; border:none; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;"&gt;
                          &lt;tbody&gt;
                            &lt;tr&gt;
                              &lt;td style="width:20em;"&gt;
                                &lt;span&gt;
  DSL - LSD/ULSD&lt;/span&gt;
                              &lt;/td&gt;
                              &lt;td style="width:60em;"&gt;
                                &lt;span id="CVSpan"&gt;
  &lt;span style="margin-right:10px"&gt;
  &lt;span style="float:left;padding-top:3px"&gt;
  Currently:&lt;/span&gt;
                                &lt;span style="float:left;width:6em;padding-top:2px; margin-left:5px; margin-right:5px;margin-top:2px;padding-bottom:2px; text-align:center; background-color:#00FF00;"&gt;
  Available&lt;/span&gt;
                                &lt;span style="float:left; padding-top:3px"&gt;
  &lt;b&gt;
  30,839&lt;/b&gt;
  gallons remaining until Mon 8/1/2016 12:00:00 AM CDT&lt;/span&gt;
                                &lt;/span&gt;
                                &lt;/span&gt;
                              &lt;/td&gt;
                              &lt;td align="right"&gt;
                              &lt;/td&gt;
                            &lt;/tr&gt;
                          &lt;/tbody&gt;
                        &lt;/table&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr style=""&gt;
                      &lt;td style="width:5px;"&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                        &lt;table id="ProdDetails" rules="all" pagerstyle-visible="False" style="width: 100%" border="1"&gt;
                          &lt;tbody&gt;
                            &lt;tr class="table_header2"&gt;
                              &lt;th scope="col"&gt;
                                Nominated Volume&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Allocation Period&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Allocation %&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Allocation Start Amt&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Allocation Lifted&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Allocation Remaining&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                GPO Allowance&lt;/th&gt;
                              &lt;th scope="col" class="center width8em"&gt;
                                GPO Remaining&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Category Status&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Ratability Status&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Next Scheduled Refresh Date&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Reference ID&lt;/th&gt;
                            &lt;/tr&gt;
                            &lt;tr class="tablerow2"&gt;
                              &lt;td class="right width8em"&gt;
                                41,118&lt;/td&gt;
                              &lt;td class="center width10em"&gt;
                                Daily&lt;/td&gt;
                              &lt;td class="right"&gt;
                                75%&lt;/td&gt;
                              &lt;td class="right"&gt;
                                30,839&lt;/td&gt;
                              &lt;td class="right"&gt;
                                0&lt;/td&gt;
                              &lt;td class="right"&gt;
                                30,839&lt;/td&gt;
                              &lt;td class="right"&gt;
                                0&lt;/td&gt;
                              &lt;td class="right width8em bold" id="GPO_Rmd"&gt;
  
                                0
                              &lt;/td&gt;
                              &lt;td class="center" style="background-color:#00FF00;"&gt;
                                Available&lt;/td&gt;
                              &lt;td class="center" style="background-color:#0099CC;"&gt;
                                Below Trend&lt;/td&gt;
                              &lt;td class="center width20em"&gt;
                                8/1/2016 12:00:00 AM CDT&lt;/td&gt;
                              &lt;td class="center width20emWordWrap"&gt;
                                DSL - LSD/ULSD&lt;/td&gt;
                            &lt;/tr&gt;
                            &lt;tr class="tablerow2"&gt;
                              &lt;td class="right width8em"&gt;
                                287,826&lt;/td&gt;
                              &lt;td class="center width10em"&gt;
                                Weekly&lt;/td&gt;
                              &lt;td class="right"&gt;
                                125%&lt;/td&gt;
                              &lt;td class="right"&gt;
                                359,783&lt;/td&gt;
                              &lt;td class="right"&gt;
                                114,083&lt;/td&gt;
                              &lt;td class="right"&gt;
                                245,700&lt;/td&gt;
                              &lt;td class="right"&gt;
                                0&lt;/td&gt;
                              &lt;td class="right width8em bold" id="GPO_Rmd"&gt;
  
                                0
                              &lt;/td&gt;
                              &lt;td class="center" style="background-color:#00FF00;"&gt;
                                Available&lt;/td&gt;
                              &lt;td class="center" style="background-color:#0099CC;"&gt;
                                Below Trend&lt;/td&gt;
                              &lt;td class="center width20em"&gt;
                                8/4/2016 12:00:00 AM CDT&lt;/td&gt;
                              &lt;td class="center width20emWordWrap"&gt;
                                DSL - LSD/ULSD&lt;/td&gt;
                            &lt;/tr&gt;
                            &lt;tr class="tablerow2"&gt;
                              &lt;td class="right width8em"&gt;
                                1,233,540&lt;/td&gt;
                              &lt;td class="center width10em"&gt;
                                Monthly&lt;/td&gt;
                              &lt;td class="right"&gt;
                                115%&lt;/td&gt;
                              &lt;td class="right"&gt;
                                1,418,571&lt;/td&gt;
                              &lt;td class="right"&gt;
                                1,361,264&lt;/td&gt;
                              &lt;td class="right"&gt;
                                57,307&lt;/td&gt;
                              &lt;td class="right"&gt;
                                0&lt;/td&gt;
                              &lt;td class="right width8em bold" id="GPO_Rmd"&gt;
  
                                0
                              &lt;/td&gt;
                              &lt;td class="center" style="background-color:#FFFF00;"&gt;
                                Low&lt;/td&gt;
                              &lt;td class="center" style="background-color:#00CC00;"&gt;
                                On Track&lt;/td&gt;
                              &lt;td class="center width20em"&gt;
                                8/1/2016 12:00:00 AM CDT&lt;/td&gt;
                              &lt;td class="center width20emWordWrap"&gt;
                                DSL - LSD/ULSD&lt;/td&gt;
                            &lt;/tr&gt;
                          &lt;/tbody&gt;
                        &lt;/table&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr id="GPO_Row"&gt;
                      &lt;td style="width:5px;"&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
                  &lt;/tbody&gt;
                &lt;/table&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr class="table_header"&gt;
              &lt;td style="width:5px;" onclick="ShowHideDetails(this)"&gt;
                &lt;img class="HideImage" src="Images/minus.gif" alt="Hide Details"&gt;
              &lt;/td&gt;
              &lt;td style="width:33%"&gt;
                Channel of Trade&lt;/td&gt;
              &lt;td style="width:33%"&gt;
                PILOT TRAVEL CENTE-122194-W/S - UNB Fwrd Cont&lt;/td&gt;
              &lt;td style="width:33%"&gt;
                &lt;span id="TruckLoading_17049566_Info" style="COLOR: white;text-decoration:underline;cursor:pointer" onclick="GetTruckLoadingInformationJS(this,17049566);"&gt;
  Trucks loading - 0&lt;/span&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td style="width:5px;"&gt;
              &lt;/td&gt;
              &lt;td colspan="3"&gt;
                &lt;table rules="rows" class="reportTable" font-family="Tahoma" pagerstyle-visible="False" id="TerminalGrid" border="1"&gt;
                  &lt;tbody&gt;
                    &lt;tr class="productlabel2" align="left"&gt;
                      &lt;td scope="col" style="width:5px;"&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                        Product Details&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr class="hdr2"&gt;
                      &lt;td scope="col" style="width:5px;"&gt;
                      &lt;/td&gt;
                      &lt;td scope="col"&gt;
                        Fuel Type&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr class="FuelTypeHeader"&gt;
                      &lt;td style="width:5px;border:none" onclick="ShowHideDetails(this)"&gt;
                        &lt;img class="HideImage" src="Images/minus.gif" alt="Hide Details" id="Fuel_Img"&gt;
                      &lt;/td&gt;
                      &lt;td style="border-left:none;border-right:none; padding-left:3px"&gt;
                        &lt;table id="C_V" style="width:100%;border-collapse:collapse; border:none; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;"&gt;
                          &lt;tbody&gt;
                            &lt;tr&gt;
                              &lt;td style="width:20em;"&gt;
                                &lt;span&gt;
  DSL - LSD/ULSD&lt;/span&gt;
                              &lt;/td&gt;
                              &lt;td style="width:60em;"&gt;
                                &lt;span id="CVSpan"&gt;
  &lt;span style="margin-right:10px"&gt;
  &lt;span style="float:left;padding-top:3px"&gt;
  Currently:&lt;/span&gt;
                                &lt;span style="float:left;width:6em;padding-top:2px; margin-left:5px; margin-right:5px;margin-top:2px;padding-bottom:2px; text-align:center; background-color:#FF0000;"&gt;
  Out&lt;/span&gt;
                                &lt;span style="float:left; padding-top:3px"&gt;
  &lt;b&gt;
  0&lt;/b&gt;
  gallons remaining until Mon 8/1/2016 12:00:00 AM CDT&lt;/span&gt;
                                &lt;/span&gt;
                                &lt;/span&gt;
                              &lt;/td&gt;
                              &lt;td align="right"&gt;
                              &lt;/td&gt;
                            &lt;/tr&gt;
                          &lt;/tbody&gt;
                        &lt;/table&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr style=""&gt;
                      &lt;td style="width:5px;"&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                        &lt;table id="ProdDetails" rules="all" pagerstyle-visible="False" style="width: 100%" border="1"&gt;
                          &lt;tbody&gt;
                            &lt;tr class="table_header2"&gt;
                              &lt;th scope="col"&gt;
                                Nominated Volume&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Allocation Period&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Allocation %&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Allocation Start Amt&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Allocation Lifted&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Allocation Remaining&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                GPO Allowance&lt;/th&gt;
                              &lt;th scope="col" class="center width8em"&gt;
                                GPO Remaining&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Category Status&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Ratability Status&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Next Scheduled Refresh Date&lt;/th&gt;
                              &lt;th scope="col"&gt;
                                Reference ID&lt;/th&gt;
                            &lt;/tr&gt;
                            &lt;tr class="tablerow2"&gt;
                              &lt;td class="right width8em"&gt;
                                0&lt;/td&gt;
                              &lt;td class="center width10em"&gt;
                                Custom 1 day(s)&lt;/td&gt;
                              &lt;td class="right"&gt;
                                100%&lt;/td&gt;
                              &lt;td class="right"&gt;
                                0&lt;/td&gt;
                              &lt;td class="right"&gt;
                                0&lt;/td&gt;
                              &lt;td class="right"&gt;
                                0&lt;/td&gt;
                              &lt;td class="right"&gt;
                                0&lt;/td&gt;
                              &lt;td class="right width8em bold" id="GPO_Rmd"&gt;
  
                                0
                              &lt;/td&gt;
                              &lt;td class="center" style="background-color:#FF0000;"&gt;
                                Out&lt;/td&gt;
                              &lt;td class="center" style="background-color:#0099CC;"&gt;
                                Below Trend&lt;/td&gt;
                              &lt;td class="center width20em"&gt;
                                8/1/2016 12:00:00 AM CDT&lt;/td&gt;
                              &lt;td class="center width20emWordWrap"&gt;
                                MERC-DSL&lt;/td&gt;
                            &lt;/tr&gt;
                          &lt;/tbody&gt;
                        &lt;/table&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr id="GPO_Row"&gt;
                      &lt;td style="width:5px;"&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
                  &lt;/tbody&gt;
                &lt;/table&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I wanted to know how to loop the table so i can get a contracts that's the "    PILOT TRAVEL CENTE-122194-W/S - UNB Contract","PILOT TRAVEL CENTE-122194-W/S - UNB Fwrd Cont" and "UNB Spot" along with the data of the table also.
  Thanks in advance.</p>