HTML Parser Issue

6 posts, 0 answers
  1. Patrick
    Patrick avatar
    7 posts
    Member since:
    Oct 2010

    Posted 31 May 2012 Link to this post

    When assigning the following table to HTMLTABLE, it is unable to parse the rows.  Therefore the row count is 0 and i am unable to validate the contents.  According to the debugger, it is finding the table, just not parsing the rows.

    any help would be appreciated.

    Code:
    //Find The main Grid
    HtmlDiv GridDiv = ActiveBrowser.Find.ById<HtmlDiv>("globalSearchGrid");
    //Find The Content
    HtmlDiv Content = GridDiv.Find.ByAttributes<HtmlDiv>("class=k-grid-content");
    HtmlTable ContenthtmlTable = Content.Find.ByTagIndex<HtmlTable>("table", 0);

    Debugger Output:



    ContenthtmlTable    {HtmlTable:<table style="height: auto;" id="globalSearchGrid-grid-table" class="k-focusable" cellSpacing="0">} 

    HTML:

    <
    table id="globalSearchGrid-grid-table" cellspacing="0" style="height: auto;" class=
    "k-focusable">
      <colgroup>
        <col />
        <col />
        <col />
        <col />
        <col />
      </colgroup>
     
      <tbody>
        <tr>
          <td class=""><input type="checkbox" /></td>
     
          <td><span>Test Matter</span></td>
     
          <td><span>5000000092</span></td>
     
          <td><span>2007-03-22T00:00:00</span></td>
     
          <td><span>Open</span></td>
        </tr>
     
        <tr>
          <td><input type="checkbox" /></td>
     
          <td class=""><span>ITP Budget Matter 2</span></td>
     
          <td><span>5000000023</span></td>
     
          <td><span>2006-04-11T00:00:00</span></td>
     
          <td><span>Open</span></td>
        </tr>
     
        <tr>
          <td><input type="checkbox" /></td>
     
          <td><span>test123123123</span></td>
     
          <td><span>5000000098</span></td>
     
          <td><span>2007-08-20T00:00:00</span></td>
     
          <td><span>Open</span></td>
        </tr>
      </tbody>
    </table>
  2. Patrick
    Patrick avatar
    7 posts
    Member since:
    Oct 2010

    Posted 31 May 2012 Link to this post

    Update:

    If i use 
    HtmlTable ContenthtmlTable = Content.Find.ById<HtmlTable>("globalSearchGrid-grid-table");


    Rather then  

    HtmlTable ContenthtmlTable = Content.Find.ByTagIndex<HtmlTable>("table", 0);

    it will work.  However i cannot use any of the attributes.
    i need it to work with the first instance of "table".
    
    
    






  3. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 31 May 2012 Link to this post

    Hello Patrick,

    I am unable to replicate the behavior you describe. In other words, the following code:

    HtmlDiv gridDiv = Find.ById<HtmlDiv>("globalSearchGrid");
    HtmlDiv content = gridDiv.Find.ByAttributes<HtmlDiv>("class=k-grid-content");
     
    HtmlTable table = content.Find.ByTagIndex<HtmlTable>("table", 0);
    Log.WriteLine("Rows Count: " + table.Rows.Count.ToString());
     
    foreach (HtmlTableRow row in table.AllRows)
    {
        foreach (HtmlTableCell cell in row.Cells)
        {
            Log.WriteLine(cell.InnerText);
        }
    }

    ...works for me against this HTML:

    <div id="globalSearchGrid">
      <div class="k-grid-content">
     
    <table id="globalSearchGrid-grid-table" cellspacing="0" style="height: auto;" class="k-focusable">
      <colgroup>
        <col/>
        <col/>
        <col/>
        <col/>
        <col/>
      </colgroup>
      
      <tbody>
        <tr>
          <td class=""><input type="checkbox"/></td>
          <td><span>Test Matter</span></td>
          <td><span>5000000092</span></td
          <td><span>2007-03-22T00:00:00</span></td>
          <td><span>Open</span></td>
        </tr>
        <tr>
          <td><input type="checkbox"/></td>
          <td class=""><span>ITP Budget Matter 2</span></td>
          <td><span>5000000023</span></td>
          <td><span>2006-04-11T00:00:00</span></td>
          <td><span>Open</span></td>
        </tr>
        <tr>
          <td><input type="checkbox"/></td>
          <td><span>test123123123</span></td>
          <td><span>5000000098</span></td>
          <td><span>2007-08-20T00:00:00</span></td>
          <td><span>Open</span></td>
        </tr>
      </tbody>
    </table>
     
      </div>
    </div>

    And here's the log output:

    '5/31/2012 4:58:46 PM' - LOG: Rows Count: 3
    '5/31/2012 4:58:46 PM' - LOG:
    '5/31/2012 4:58:46 PM' - LOG: Test Matter
    '5/31/2012 4:58:46 PM' - LOG: 5000000092
    '5/31/2012 4:58:46 PM' - LOG: 2007-03-22T00:00:00
    '5/31/2012 4:58:46 PM' - LOG: Open
    '5/31/2012 4:58:46 PM' - LOG:
    '5/31/2012 4:58:46 PM' - LOG: ITP Budget Matter 2
    '5/31/2012 4:58:46 PM' - LOG: 5000000023
    '5/31/2012 4:58:46 PM' - LOG: 2006-04-11T00:00:00
    '5/31/2012 4:58:46 PM' - LOG: Open
    '5/31/2012 4:58:46 PM' - LOG:
    '5/31/2012 4:58:46 PM' - LOG: test123123123
    '5/31/2012 4:58:46 PM' - LOG: 5000000098
    '5/31/2012 4:58:46 PM' - LOG: 2007-08-20T00:00:00
    '5/31/2012 4:58:46 PM' - LOG: Open

    What are we doing differently?

    All the best,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  4. Patrick
    Patrick avatar
    7 posts
    Member since:
    Oct 2010

    Posted 04 Jun 2012 Link to this post

    interesting. 
    I'm running on 2012.1.411.0, is your version different?


  5. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 04 Jun 2012 Link to this post

    Hello Patrick,

    Yes, I'm using the latest official service pack: version 2012.1.528. Consider upgrading and testing this code again.

    Kind regards,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  6. Patrick
    Patrick avatar
    7 posts
    Member since:
    Oct 2010

    Posted 04 Jun 2012 Link to this post

    The combination of upgrading and adding Ajax waits fixed my Issue.

    It was most likely that it was an Ajax issue the whole time. I imagine that the "FindByID" is a slower process then "ByTagIndex", therefore allowing more time for the ajax table to load. Ether way it now works, 

    Thanks for all your help!.
Back to Top