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?  

6 REPLIES 6
Marsha_R
Champion Level 3

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

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

then use that variable where you need the link
Aurelia
Occasional Visitor

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

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.

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

romrellob
Occasional Contributor

Thanks,  This works.

romrellob
Occasional Contributor

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: