cancel
Showing results for 
Search instead for 
Did you mean: 

Search object using Name attribute

Highlighted
Occasional Contributor

Search object using Name attribute

I am trying to search for object using the Name attirbute but it does not seems to work, below is my code :

firstly i search for object using contentText then i obtain the Name which is successful and the result is :

PropValue = Cell(1, 2) then when i use PropValue to search for contentText, it does not work, please help.

 

          var page = Sys.Browser("Chrome").Page("*");
          var link = page.NativeWebObject.Find("contentText","ABC","td");
          link.Click();         
          var PropValue = aqObject.GetPropertyValue(link, "Name");
          Log.Message(PropValue);
                   
          var GetValue2 = page.NativeWebObject.Find("Name",PropValue,"td"); 
          var intPass = aqObject.GetPropertyValue(GetValue2, "contentText"); // the test fail here, no object return
          Log.Message(intPass);

5 REPLIES
Community Hero

Re: Search object using Name attribute

Are you sure that the object you want is actually available at that time?

 

Try this part of your code again except use the known values instead of the variables or properties.  See if you can get it to come up that way first.

 

var GetValue2 = page.NativeWebObject.Find("Name",PropValue,"td"); 
          var intPass = aqObject.GetPropertyValue(GetValue2, "contentText"); // the test fail here, no object return
          Log.Message(intPass);

Occasional Contributor

Re: Search object using Name attribute

hi Marsha_R,

 

thanks for your reply.

yes, the object is available at that time.

it is actually a cell from a table and i am trying to get the value from that particuler cell in the table.

 

PropValue = Cell(1, 2)

 

var GetValue2 = page.NativeWebObject.Find("Name","Cell (1,0)","td"); 
var intPass = aqObject.GetPropertyValue(GetValue2, "contentText");

Log.Message(intPass);

 

Error message that i encounter : The object "item" does not exist.

Community Hero

Re: Search object using Name attribute

Try just these lines of code but put all the actual values in the right hand side, then post a screenshot of the results please.  There's something missing and we need to see exactly what's happening.

 

var intPass = aqObject.GetPropertyValue(GetValue2, "contentText");

Log.Message(intPass);

Occasional Contributor

Re: Search object using Name attribute

Hi Marsha_R,

 

Thank you for your reply.

I don't know why i still can't search object using Name attibute

Instead of using Name i now change to ObjectIdentifier

 

var GetValue2 = page.NativeWebObject.Find("ObjectIdentifier",intValue,"td");
var intPass = aqObject.GetPropertyValue(GetValue2, "contentText");
Log.Message(intPass);

the code above work well without any problem for me.

Community Hero

Re: Search object using Name attribute

Hi,

 

> can't search object using Name attibute

Are you talking about object's Name property displayed in the Object Browser or about Name attribute in the HTML markup?

 

In the former case, the search by the Name property is not recommended in TestComplete. See Remarks section of the Find Method help topic for more details.

In the latter case, the search for the object by its markup attribute was added to the TestComplete 12.60 Beta (https://community.smartbear.com/t5/TestComplete-General-Discussions/TestComplete-Beta-Program-Try-AI...).

 

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/
================================
Share Your Stories
Read Latest News
Top Kudoed Authors