Ask a Question

How do you parameterize object locators in TestComplete

SOLVED
romrellob
Occasional Contributor

How do you parameterize object locators in TestComplete

I am using data driven test methods.  Some of the links in our web app are titles of works and include the title string in the link locator,  How can I parameterize the locator to use the data string supplied in the excel file for the data loop?  

1 ACCEPTED SOLUTION

Accepted Solutions
Marsha_R
Community Hero

Re: How do you parameterize object locators in TestComplete

Well, now that we have the complete question, perhaps we can get you a complete answer!

 

You can tell the name mapping to use a project variable.  Build the variable as I described before and assign that variable in this dialog.

https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/dial...

Marsha_R
[Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

View solution in original post

6 REPLIES 6
Marsha_R
Community Hero

Re: How do you parameterize object locators in TestComplete

You can use a string variable to build your own link.

"beginningoflinkgoeshere"+Eval(referencetoexcelgoeshere)+"endoflinkgoeshere"

then use that variable where you need the link
Marsha_R
[Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
Aurelia
Occasional Visitor

Re: How do you parameterize object locators in TestComplete

Add the Find Object operation to your keyword test. Specify the object TestComplete will search for and click Next..Specify the list of object properties to check and the property values for the sought-for object: ..Choose the found object's method to call and click Finish.

 

skylight paycards

romrellob
Occasional Contributor

Re: How do you parameterize object locators in TestComplete

Both of your replies have been helpful but not the complete answer.  

 

In the "Edit Name Mapping Item" window, I want to create a selector that will pull a string value from a data source as shown in the attached screenshot.

 

The highlighted selector works the best but only when the text value matches.

 

Any suggestions would be helpful.

Marsha_R
Community Hero

Re: How do you parameterize object locators in TestComplete

Well, now that we have the complete question, perhaps we can get you a complete answer!

 

You can tell the name mapping to use a project variable.  Build the variable as I described before and assign that variable in this dialog.

https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/dial...

Marsha_R
[Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

View solution in original post

romrellob
Occasional Contributor

Re: How do you parameterize object locators in TestComplete

Thanks,  This works.

romrellob
Occasional Contributor

Re: How do you parameterize object locators in TestComplete

OK,  After getting this working I wanted to post What I actually did.

I was not able to create the project string variable the way that Marsha_R described.  

""beginningoflinkgoeshere"+Eval(referencetoexcelgoeshere)+"endoflinkgoeshere""

 

I consistently got an error whenever I used the Eval function in the "Set Variable Value" dialog.

Inside of a script this may work just fine.

 

I also could not concatenate the value from my table data with any other string in the "Set Variable Value" function. 

 

To get this to work I created a variable with just the table data in it.

romrellob_1-1635807051608.png

 

After that I was able to create the variable with the string that I needed.

romrellob_2-1635807167901.png

                                                       '//a[.="'+Project.Variables.SearchResultsTitleString+'"]'

 

To set the locator property, I used the following.     %SearchResultsTitleLocator%

NOTE:  you do not use the "Project.Variables." prefix when referencing the variable here.  It is expecting this to be a project variable.  Adding the prefix will cause a runtime error.  Also, you have to enclose the variable name with "%". 

 

Now when I run my test, I can select the list element by the title name and get the specific Item that I am looking for.

 

Winner Winner Chicken Dinner !!!

 

The following documents were very helpful.

https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/dial...

https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/basi...

 

 

 

 

 

cancel
Showing results for 
Search instead for 
Did you mean: