Silverlight- How to get headers from the datagrid

I was automating one Silverlight application and struck into the columns headers. for some Columns qtp was not able to fetch the correct header value. It was only giving back numerical values while my columns were having strings (shown in below figures). It was simply returning the column no:

Following is my application:
I was trying to get the column headers and then the whole table to store into two dimensional array. When i executed the following statement it was giving weird results.

For i =1 to 15
print Browser("JobCenter").Page("JobCenter").SlvWindow("MainPage").SlvTable("revenueAtAGlanceDashboard").SlvTable("CountriesRevenueAtAGlancDashboard").GetCellProperty(1,i,"colname") & " Col no - " & i
Next
 
For col no 7 and up it was giving col no; instead of heading. Not sure what was the issue and even developers said they can't help as they can't find a specific region for this behaviour.

I looked around on msdn and went through datagrid controls. Through some research and googling i understood that we can also fetch the columns headers by using datagrid columns collection but no such material is available on the internet.

I create first the columns collections objects:

Dim objColHeader:Set objColHeader=Browser("JobCenter").Page("JobCenter").SlvWindow("MainPage").SlvTable("revenueAtAGlanceDashboard").SlvTable("CountriesRevenueAtAGlancDashboard").Object.Columns

then by using its item and header property i was able to fine the header name:

Dim colName:colName=objColHeader.Item(cCounter).Header

results:
By executing the following statement:
Set objColHeader=Browser("JobCenter").Page("JobCenter").SlvWindow("MainPage").SlvTable("revenueAtAGlanceDashboard").SlvTable("CountriesRevenueAtAGlancDashboard").Object.Columns

For i =1 to 15
colName=objColHeader.Item(i).Header
print colName
Next
 


















Moreover this method is much faster then by simply taking data from getcelldata. The 2nd method took only 2.4 secs

Comments

  1. I had the similar issues with Silverlight table header. After going over your post, i'm able to read column names of silverlight tables from our application.
    It was very helpful post.

    Thanks,
    Muhshin
    usa718@gmail.com

    ReplyDelete

Post a Comment

Popular posts from this blog

Test Batch Runner - Run QTP Scripts from xls file

Selenium: db and excel data into maps

Python: get entire workbook data cell by cell