Variable in href test object

Is there a way to use a global variable in a href test object?

Here’s the href:
workflowView.do?id=124&calendar=16&item=12&date=12/03/2018&time=18:00

I need to run my test case and replace the date by a global variable (or another type of variable). I need to use the href and the text to identify the element on the web page. xPath is not unique.

Steve,

did you try to use “${GlobalVariable.var}” where do yo want to get the value?

Hi,

G_Date is my global variable.

I tried this in the href value test object: workflowView.do?id=124&calendar=16&item=12&date=${GlobalVariable.G_Date}&time=18:00

I even tried with double quote: workflowView.do?id=124&calendar=16&item=12&date="${GlobalVariable.G_Date}"&time=18:00

I even tried double double quote: workflowView.do?id=124&calendar=16&item=12&date=""${GlobalVariable.G_Date}""&time=18:00

Single quote: workflowView.do?id=124&calendar=16&item=12&date=’${GlobalVariable.G_Date}’&time=18:00

Double single quote: workflowView.do?id=124&calendar=16&item=12&date=’’${GlobalVariable.G_Date}’’&time=18:00

I can see the concat function getting call in some cases. Here’s the log for double single quote:
located by ‘By.xpath: //a[@href = concat(‘workflowView.do?id=124&calendar=16&item=12&date=’ , "’" , ‘’ , “’” , ‘${GlobalVariable.G_Date}’ , “’” , ‘’ , “’” , ‘&time=18:00’) and (text() = ’

I can’t figure out the right syntax.

Thanks.

Steve,

Sorry for my bad. We could not use the variable directly now. Here is the solution:
- Specify a variable in the href as below:
- In the test case (calling the rest object), use following script to put Globalvariable into the variable

WebUI.click(findTestObject('Page_CuraHomepage/btn_MakeAppointment', [('var1') : GlobalVariable.G_href]))

Hope that it helps.

We also put this issue as an enhancement in our backlog.

29104336_174774623314627_4832741465392152576_n.png

Hi,
This is working. It’s not perfect in my scenario since I only have a part of the href that’s dynamic. But still, it’s working for now.
Perfect feature would be to be able to put a variable inside a href value. Like:
something, $Global.var, somethingelse
Thanks.

I’m sure I read how to build that kind of string in Groovy. If I bump into it again I’ll drop a line here.