Ask a Question

nameMapping- How to pass project variable in the namemapping xpath

tvklovesu
Frequent Contributor

nameMapping- How to pass project variable in the namemapping xpath

Hello,

I thought I saw somewhere but can't find the answer for this again. I am trying to pass variable that's defined in the project Temp variables section and combine with a text. 

for ex: Xpath = //div[.='abcd']

I want something like 

Xpath = //div[.=Project.variables.myText]

 

Same for url

URL = http://Project.variables.MyURL/webpage.html

This URL will be different from Lower environment to Prod. So I can't just user * in the url part.

 

Thanks

7 REPLIES 7
KB1
Champion Level 2
Champion Level 2

This is what I would try:

 

let Test = frame.FindElement("//div[.='" + Project.Variables.Name + "']");

tvklovesu
Frequent Contributor

Thanks for the reply. I am looking to pass variable in to nameMapping repository. I know how to do with in the script. But my project is in Keyword test and I need to pass URL for page and some test data for objects.

KB1
Champion Level 2
Champion Level 2

Sorry I haven't tried keyword based testing But I think you can try only adding: 

div[.='" + Project.Variables.Name + "']" to the keyword

tvklovesu
Frequent Contributor

Sorry, If I confused you. I want that variable to be used in the nameMapping window as shown in below. I saw in one of the post sometime back that only project variables can be used in the nameMapping objects. but can't find that exact syntax. The below syntax is not working for me.

 

tvklovesu_0-1666965143459.png

 

tvklovesu
Frequent Contributor

I found this page with an example, but still TC is not able to find the page object

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

 

Project.Variables.MyURL = "https://ea-webapp-dev-raven.com/"

URL= %Project.Variables.MyURL%email-batches/*

 

tvklovesu_0-1667065906650.png

 

Not sure whats wrong I am doing here. Can someone please help me

Thanks

 

KB1
Champion Level 2
Champion Level 2

Learn how to create variables for keyword tests, projects, and project suites, and how to use them to replace hard-coded values in your TestComplete tests with other data. Try TestComplete for free today: https://smartbear.com/product/testcomplete/free-trial/. Helpful Links: * Web Testing ...
rraghvani
Champion Level 3

Here's an example using Code Expression,

rraghvani_0-1667228029860.png

Project.Variables.MyVariable is set to "https://community.smartbear.com", and I want to add "/t5/TestComplete/ct-p/TestComplete_forum". The URL will then come "https://community.smartbear.com/t5/TestComplete/ct-p/TestComplete_forum"

cancel
Showing results for 
Search instead for 
Did you mean: