cancel
Showing results for 
Search instead for 
Did you mean: 

Insert variables in a dynamic URL

SOLVED
Highlighted
Contributor

Insert variables in a dynamic URL

Hi,

 

Could someone help, please - I'm trying to code URL that has got dynamic variables?.

 

The mapping name is:

Aliases.browser.Page("https://www.busstage.com/regionaltickets/west-area/London/megarider").Panel(0).Panel(3).Panel(0).Panel(0).Panel(3).Panel(0).Panel(1).Panel(2).Panel(0).Panel(0).Panel(0)

 

Knowing that, west-area and  London are dynamic. 

 

I've tried the following code but is not working:

var Var1 = DDT.CurrentDriver.Value("Location"); //location is passed from spreadsheet.

 

Aliases.browser.Page("https://www.busstage.com/regionaltickets/?*/@Var1/megarider").Panel(0).Panel(3).Panel(0).Panel(0).Panel(3).Panel(0).Panel(1).Panel(2).Panel(0).Panel(0).Panel(0)

 

Regards,

A.M.

 

 

 

A.M.
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Insert variables in a dynamic URL

Your variables are inside double quote. So they'll be treated as part of the string.

 

Try:

 

"https://www.busstage.com/regionaltickets/*/" + Var1 + "/megarider"

 

(Not sure what language you're using. May need to use & instead of + to concat the string parts)

View solution in original post

3 REPLIES 3
Highlighted
Community Hero

Re: Insert variables in a dynamic URL

Your variables are inside double quote. So they'll be treated as part of the string.

 

Try:

 

"https://www.busstage.com/regionaltickets/*/" + Var1 + "/megarider"

 

(Not sure what language you're using. May need to use & instead of + to concat the string parts)

View solution in original post

Highlighted
Occasional Contributor

Re: Insert variables in a dynamic URL

Hello,

 

I have a similar issue wherein I recorded my script for production environment but want it to run on Staging environment. I am using the below 

Aliases.browser.pageVirtualiticsComAboutUs.section.panel.panel.panel.panel.panel.panel.panel


where VirtualiticsCom needs to be dynamic. I have stored the url in a parameter named Param1. This can be to set the url for any environment thereby not affecting the content of webpage

How can I only change the underlined part so that it goes through staging environment?

 

Thankyou!

 

Highlighted
Community Hero

Re: Insert variables in a dynamic URL

Hi,

 

> How can I only change the underlined part

In the NameMapping editor change identification URL parameter from hardcoded string to reference your Param1 parameter (https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/mana...).

 

P.S.. Also: https://support.smartbear.com/screencasts/testcomplete/reliable-tests-for-dynamic-objects/ (from https://support.smartbear.com/screencasts/testcomplete/)

 

Regards,
  /Alex [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
================================
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors