This is a migrated thread and some comments may be shown as answers.

HTML Parser Issue

5 Answers 138 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 31 May 2012, 07:51 PM
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>

5 Answers, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
answered on 31 May 2012, 08:59 PM
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".








0
Anthony
Telerik team
answered on 31 May 2012, 11:02 PM
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
0
Patrick
Top achievements
Rank 1
answered on 04 Jun 2012, 01:30 PM
interesting. 
I'm running on 2012.1.411.0, is your version different?


0
Anthony
Telerik team
answered on 04 Jun 2012, 02:00 PM
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
0
Patrick
Top achievements
Rank 1
answered on 04 Jun 2012, 03:27 PM
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!.
Tags
General Discussions
Asked by
Patrick
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
Anthony
Telerik team
Share this question
or