cancel
Showing results for 
Search instead for 
Did you mean: 

Finding object by using dynamic xpath, using Partial Content text

Community Hero

Re: Finding object by using dynamic xpath, using Partial Content text

Or you can use the title of the grid as anchor:

 

.//h4[text()="Basic Example"]/following::div[1]
Community Hero

Re: Finding object by using dynamic xpath, using Partial Content text

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.

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Occasional Contributor

Re: Finding object by using dynamic xpath, using Partial Content text

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);
 
}

Community Hero

Re: Finding object by using dynamic xpath, using Partial Content text

You should define page variable. 

 

page = Sys.Browser("*").Page("*")
Community Hero

Re: Finding object by using dynamic xpath, using Partial Content text

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/findall...

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Occasional Contributor

Re: Finding object by using dynamic xpath, using Partial Content text

Please illustrate an example on how to write dynamic xpaths in Testcomplete tool.

Ex: //*[@id='signout']/div[1]

Occasional Contributor

Re: Finding object by using dynamic xpath, using Partial Content text

Please illustrate an example on how to write dynamic xpaths as we use to write in Eclipse as ByXpath("//*[@id='signout']/div[1]") and if possible please make a video.

Ex: //*[@id='signout']/div[1]

Community Hero

Re: Finding object by using dynamic xpath, using Partial Content text

You can test your xpath directly in your browser (e.g. using developer tools). If it works there, it will work also with TestComplete.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors