Forum Discussion
I am trying to
Url: http://ui-grid.info/
Angualr UI grid
I am trying to get the values of the upper grid. I need to capture those values from the table and verify them with the values in Excel sheet in Test complete.
I used all the three types of finding the object,none of them worked. Please verify following script and let me know where I am going wrong.
Thank you for co operation in advance
function VerifyGridValue(textValue)
{
Sys.Browser("*").Page("*").Wait("10000");
var obj = Sys.Browser("*").Page("*").FindChildByXPath(".//*[@id='150952'" + * + "'-grid-container']/div[2]/div]");
//Sys.Browser("*").Page("*").FindChildByXPath("//*[@class='" + ui-grid-canvas + "']")
//var obj = Sys.Browser("*").Page("*").FindChildByXPath(".//*div[contains(@id, "150952") and contains(@id, "grid-container")]/div[2]/div]");
var val=obj.wValue(0,1);
switch (true)
{
case IsSupported(obj, val) == true && textValue :
Log.Checkpoint("Value match as expected");
break;
default:
Log.Error("Text values do not match!");
}
Log.CallStackSettings;
}
Hi,
Thank you a lot for the link provided.
Fantastic example, directly from the product provider, of how the product can be created with the absolute ignorance of automated testing. Bookmarked.
The problem with all Angular controls that I've seen so far is that (by default?) they provide no unique and stable identifiers. The only entities that can be used to address UI elements is usually class name and visible text. I am pretty sure it is needless to say how unreliable this is.
Anyway, assuming that there is only one table on the page with the 'grid_container' identifier, personally I would do it like this:
-- search for the table container (tableContainer = page.FindChild(['ObjectType', 'ObjectIdentifier'], ['Panel', 'grid_container'], 10));
-- Using table container as the root, search for all 'uiGrid_0007_cell' elements that correspond to the data cells of the first column (arCells = tableContainer.FindAllChildren(['ObjectType', 'ObjectIdentifier'], ['Panel', 'uiGrid_0007_cell'], 10).toArray() ) (Note: the array will be in reverse order, i.e. the first array element will correspond to the last column cell - this is specific of how TestComplete's .FindAllChildren() method works);
-- Iterate through the returned array and get the value of the contentText property to get first column cell values.
- AlexKaras7 years agoChampion Level 3
In addition to the note by baxatob:
.FindAllChildren() returns an array, thus while
console.log(Cells);
will work if executed from command line via cscript engine, the same line will fail in TestComplete as there is no console object.
You will need to either convert the array to string or iterate through it. Code example can be found, for example, here: http://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/findallchildren-method.html
- muhammadA7 years agoOccasional Contributor
Thank you Alex. It was really good approach .
I executed the following code , please verify and I am getting JScript runtime error 'page' is undefined . Please correct me where I am going wrong. I attach screen shot
function VerifyGridValue(textValue)
{
Sys.Browser("*").Page("*").Wait("10000");
tableContainer = page.FindChild(['ObjectType', 'ObjectIdentifier'], ['Panel', 'grid_container'], 10);
var Cells = tableContainer.FindAllChildren(['ObjectType', 'ObjectIdentifier'], ['Panel', 'uiGrid_0007_cell'], 10).toArray() ;
console.log(Cells);
} - baxatob7 years agoCommunity Hero
You should define page variable.
page = Sys.Browser("*").Page("*")
Related Content
- 3 years ago