cancel
Showing results for 
Search instead for 
Did you mean: 

Grid issue on web Applications

Super Contributor

Grid issue on web Applications

We are working on grid. We need to select the cell. But the testComplete Object Spy do not recognize this object as grid type .

Attached the screenshot. 

 

Is there any generic function that can take any grid and select the cell ?

7 REPLIES 7
Community Leader

Re: Grid issue on web Applications

It looks like you are using some third party extension like DvExpress or equivalent.  These tools don't always generate tables, rather they use fancy CSS to make it "look" like a table.  Your best bet would probably be to try and get an understanding of what structure this third party tool uses to construct this table.  use a name mapping of the "Table" - Panel("grdNBrjbd") and then use a FindChild/FindChildren with one of the parameters being property/values you are looking for being a textnode with text "131038" in

e.g. 

 

var props = ["ObjectType","contentText"];
var values = ["TextNode","131038"];     //this may be something like "INPUT".  Also, you may want to pass the text as a parameter
//I see you can have multiple rows with the same number, so you either have to
//find something even more unique, or use FindAllchildren
var panelElements = yourGridTable.FindAllChildren(props,values,5).toArray();
var textNode = null; for(i==0;i<panelElements.length;i++
{
//some boolean logic
if(panelElements[i].[EvenMoreDistinctProperty] == [distinctValue])
{
textNode = panelElements[i];
break;
}
//though if you get here you problby could have used FindChild/FindChilEx
//but this is here because you may find this approach needed in other places
//where you may need an array of items
}

if(textNode.Exists && textNode.Parent.Exists)
{
textNode.Parent.Click();
}

You will want to add some extra property and waits just in case, but there's the general idea


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Super Contributor

Re: Grid issue on web Applications

thanks for the updates .

 

Structure is using slickgrid UI plugin.

 

 

has anyone ever worked on slickgrid ?

 

 

Community Leader

Re: Grid issue on web Applications

Wish I could help, but no.  Not familiar with it at all Smiley Sad


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Super Contributor

Re: Grid issue on web Applications

@RUDOLF_BOTHMA

 

I need to select the row based on multiple columns . The row is unique based on the multiple columns. Attached the screenshot.

 

 

Community Hero

Re: Grid issue on web Applications

The approach would still be the same as @RUDOLF_BOTHMA mentioned. You will want to findall the children that represent a row in your grid, then find the individual elements, and if they match your criteria break our of the loop. 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped
Community Leader

Re: Grid issue on web Applications

Edit: Well, smartbear threw all of that away. Have to retype...

 

Agreed @cunderw

 

Off the top of my head I'd do something like*:

 

var columnoneitems = grid.FindAllChildren(columnoneindex, columnonesearchtext).toArray();
var columntwoitems = grid.FindAllChildren(columntwoindex,columntwosearchtext).toArray();
//columnthreeitems etc.
var iFoundTheRow = false;
var theRowIs = -1;

var i = 0;
var j = 0;
//you can probably improve this.  You just need an efficient way to find the intersect of the arrays.  There should be only one rowindex that exists in all the arrays
while(i<columnoneitems.length && iFoundTheRow==false)
{
while(j<columntwoitems.length&& iFoundTheRow==false)
{
if(columnoneitems[I].RowIndex = columntwoitems[j].RowIndex)
{
iFoundTheRow = true;
theRowIs = columnoneitems[I].RowIndex
}
j++
}
I++;
}

if(iFoundTheRow)
{
var theItem = grid.FindChild(rowindex,clickcolumnindex,clickfindtext)
if(theItem.Exists)
{
theItem.Click();
}
else
{
Log.Error("Item is having an existential crisis");
}
}
else
{
Log.Error("No such Row found");
}

-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Highlighted
Community Leader

Re: Grid issue on web Applications

Had a thought on this over the weekend...

 

Performance considerations.  You could do grid.FindAll().toArray() for each text you are looking for, no matter which column they are in and add each FindAll to an array. If any of the arrays have a zero length, you can just break and say the record doesn't exist Smiley Surprised  If any of your arrays now has only one item, thats your row.  If not, do the same array logic to find the one rowindex that exists in all of them.  All about finding the shortcuts Smiley Very Happy  Since that one text element is alredy in one of your collections, you don't need to do another find.  You just go to the element in the array where the element has the columnindex you want and click the parent.  Larger arrays perhaps, but definately less Finds.  You could try the first post's columnindex first approach with the second approaches array only requirement, thereby having smaller arrays but with the same , smaller Find work that the second approach uses.


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
New Here?
Join us and watch the welcome video:
Top Kudoed Authors