title: xpath of nth td in dynamic table in Selenium/Java
body: <p>I have a dynamic table and I need to get all the values under the column "Date/Time? I'm unable to get to the /td containing Date/Time. The Td ID and Class names are all dynamic </p>
  
  <pre><code>&lt;document&gt;
   &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head id="Head1"&gt;
    &lt;body&gt;
     &lt;form id="form1" action="RunReport.aspx?ReportPath=%2fxxxxxx%2fChange+Log&amp;ReportName=Change+Log&amp;ReportOutput=--" method="post" name="form1"&gt;
      &lt;div/&gt;
      &lt;script type="text/javascript"&gt; //&lt;![CDATA[ var theForm = document.forms['form1']; if (!theForm) {     theForm = document.form1; } function __doPostBack(eventTarget, eventArgument) {     if (!theForm.onsubmit || (theForm.onsubmit() != false)) {         theForm.__EVENTTARGET.value = eventTarget;         theForm.__EVENTARGUMENT.value = eventArgument;         theForm.submit();     } } //]]&gt; &lt;/script&gt;
      &lt;script type="text/javascript" src="/xxxxxxxx/WebResource.axd?d=V7QB9aA-CMKBf_It9wv5y2DqZbRLrb5ffBwJnLkaYDr5pU-NN0s1ZPyMlic7TalUdeqQfQg0f0hBQ5vc5FRF6TGqLTthE4DKA30A-L1LPCg1&amp;t=635418606520000000"/&gt;
     &lt;script type="text/javascript" src="/xxxxxxxx/ScriptResource.axd?d=ZQO5N5aOeLdEjEooaJaTyKww9aony6pg5nLqvVGBchaBRFjQEDHDikotXjab4lpgUsn8rNEgGqrrEmvFvTEJh9XNGP0OvUXTFQk6ZnGiqxCgD6yxZEIZNQeIUFyY7s0UJiH9S_XEit5ruUgYEwmnGToVkDm1twhe03OvidFuqGs1&amp;t=7e632e9f"/&gt;
      &lt;script type="text/javascript" src="/xxxxxxxxx/ScriptResource.axd?d=TraUIU0pF-vc5erOeo272dRc6jvvl-tp1IhH8icmW9Pqh-XyqQGubtk3taZPhhwGJyBEJq2uA1HlRhC55tsZ3PBPoT81bFotHP5mZF_KuY_2NJVoyMZznUTOBX5aqbBYnW9p4FEn3lnTyUpAjLCwlpk17z9yYmrw8ErPm6dTXg0LDVW1Jt40I6C1yk-hY_j70&amp;t=7e632e9f"/&gt;
     &lt;script type="text/javascript" src="/xxxxxxxx/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=10.0.30319.1&amp;Name=ViewerScript"/&gt;
      &lt;script type="text/javascript" src="/xxxxxxxx/ScriptResource.axd?d=ZgCktqsR0I_2fhh-iIO4Abgy21lP5uMQNwtUzd_UyFfIprbIySdOXIPYBkpeZLT76IM5l0FiTvM__QYNu9JorZxtU13SyIYAffijp3IaAfJimLPcVFjaytrZe-noWDW4P0ZdWdc7kR8Vn5mci2VdV2Lj86BByElGhI9fC7p5o8k1&amp;t=7e632e9f"/&gt;
      &lt;div/&gt;
      &lt;div/&gt;
      &lt;script type="text/javascript"&gt; //&lt;![CDATA[ Sys.WebForms.PageRequestManager._initialize('Scriptmanager1', 'form1', ['fReportViewer1$ReportViewer','','fReportViewer1$Toolbar','','fReportViewer1$DocMap','','fReportViewer1$ctl10$ReportArea',''], [], ['ReportViewer1$ctl10$ReportControl$ctl00',''], 90, ''); //]]&gt; &lt;/script&gt;
      &lt;noscript&gt; &amp;nbsp;Your browser does not support scripts or has been configured not to allow scripts. &lt;/noscript&gt;
  &lt;span id="ReportViewer1_ReportViewer"&gt;
    &lt;div id="ReportViewer1" style="height: 100%; width: 100%;" onactivate="if ($get('ReportViewer1_ctl04') != null &amp;&amp; $get('ReportViewer1_ctl04').control != null) $get('ReportViewer1_ctl04').control.HideActiveDropDown();" onclick="if ($get('ReportViewer1_ctl04') != null &amp;&amp; $get('ReportViewer1_ctl04').control != null) $get('ReportViewer1_ctl04').control.HideActiveDropDown();"&gt;
        &lt;div id="ReportViewer1_HttpHandlerMissingErrorMessage" style="border-color:Red;border-width:2px;border-style:Solid;padding:10px;display:none;overflow:auto;font-size:.85em;"&gt;
        &lt;span id="ReportViewer1_ctl03"&gt;
        &lt;input id="ReportViewer1_ctl11" type="hidden" name="ReportViewer1$ctl11" value="ltr"/&gt;
        &lt;input id="ReportViewer1_ctl12" type="hidden" name="ReportViewer1$ctl12" value="standards"/&gt;
        &lt;div id="ReportViewer1_AsyncWait" style="background-color: White; opacity: 0.7; position: absolute; display: none; top: 29px; left: 0px; width: 1049px; height: 0px; z-index: 1000; visibility: hidden;"/&gt;
        &lt;div id="ReportViewer1_AsyncWait_Wait" style="cursor: wait; background-color: rgb(236, 233, 216); padding: 15px; border: 1px solid black; display: none; position: absolute; z-index: 1001; visibility: hidden; top: 0px; left: 441.5px;"&gt;
        &lt;input id="ReportViewer1_AsyncWait_HiddenCancelField" type="hidden" value="False" name="ReportViewer1$AsyncWait$HiddenCancelField"/&gt;
  </code></pre>
  
  <p>The below table id is on the same level as the above last input Id</p>
  
  <pre><code>&lt;table id="ReportViewer1_fixedTable" cellspacing="0" cellpadding="0" style="table-layout:fixed;width:100%;height:100%;"&gt;
  &lt;tbody&gt;
  &lt;tr style="background-color:#ECE9D8;"&gt;
  &lt;tr id="ParametersRowReportViewer1" style="display:none;"&gt;
  &lt;tr style="height:6px;font-size:2pt;display:none;"&gt;
  &lt;tr&gt;
  &lt;tr&gt;
    &lt;td style="vertical-align:top;width:25%;height:100%;display:none;"&gt;
    &lt;td style="display:none;width:4px;padding:0px;margin:0px;height:100%;vertical-align:middle;background-color:#ECE9D8;"&gt;
     &lt;td style="height:100%;vertical-align:top;"&gt;
    &lt;div id="ReportViewer1_ctl10" style="height:100%;width:100%;overflow:auto;position:relative;"&gt;
    &lt;div id="VisibleReportContentReportViewer1_ctl10" style="height: 100%;"&gt;
    &lt;div id="P7d543a84a5b9486884b84551ef9c3d9d_1_oReportDiv" style="WIDTH:100%;direction:ltr" dir="LTR"&gt;
    &lt;table cellspacing="0" cellpadding="0"&gt;
    &lt;tbody&gt;
     &lt;tr&gt;
      &lt;td id="P7d543a84a5b9486884b84551ef9c3d9d_1_oReportCell"&gt;
       &lt;table cellspacing="0" cellpadding="0"&gt;
        &lt;tbody&gt;
         &lt;tr&gt;
        &lt;tr&gt;
         &lt;td&gt;
          &lt;table cellspacing="0" cellpadding="0" border="0"&gt;
           &lt;tbody&gt;
            &lt;tr&gt;
             &lt;td style="vertical-align:top"&gt;
               &lt;table cellspacing="0" cellpadding="0" border="0" style="WIDTH:176.06mm;min-width:176.06mm;HEIGHT:241.30mm;"&gt;
               &lt;tbody&gt;
                &lt;tr&gt;
                 &lt;td style="vertical-align:top"&gt;
                  &lt;table class="Ada2aa9230a6045f4858a262591be2439124xB" cellspacing="0" cellpadding="0" border="0" style="WIDTH:176.06mm;min-width:176.06mm;HEIGHT:241.30mm;"&gt;
                   &lt;tbody&gt;
                    &lt;tr&gt;
                     &lt;td style="vertical-align:top"&gt;
                      &lt;table class="Ada2aa9230a6045f4858a262591be2439122" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;" cols="10"&gt;
                       &lt;tbody&gt;
                        &lt;tr height="0"&gt;
                         &lt;tr valign="top"&gt;
                          &lt;td style="HEIGHT:6.35mm"/&gt;
                            &lt;td class="Ada2aa9230a6045f4858a262591be243941c"&gt;
                               &lt;td class="Ada2aa9230a6045f4858a262591be243945c"&gt;
                                  &lt;div class="Ada2aa9230a6045f4858a262591be243945"&gt;Date/Time&lt;/div&gt;
                                     &lt;/td&gt;
  </code></pre>
  
  <p>I searched online and tried this xpath and it didn't work. Any help is appreciated</p>
  
  <pre><code>List&lt;WebElement&gt; getDates = driver
      .findElements(By
      .xpath("//table[@id='ReportViewer1_fixedTable']//tr[contains(td[11], 'Date/Time')]"));
  
      for (int i = 0; i &lt; getDates.size(); i++) {
          String strDateFrmRslt = getDates.get(i).getText();
  
      }
  </code></pre>
  
  <p>I cannot seem to post this question as I need to add more details so I am repeating my question here again
  I have a dynamic table and I need to get all the values under the column "Date/Time? I'm unable to get to the /td containing Date/Time. The Td ID and Class names are all dynamic</p>
  
  <hr>
  
  <p>SOLUTION:
  If anyone is interested. Thanks to Ian Robert's post about the xpath I was able to get all the text from the table using //table[@id='ReportViewer1_fixedTable']//tr/td[3]
   and then I got the DateTime values from there.</p>