How to place a Variable into Xpath expression?
Hello,
I want to modify an Xpath expression and include a Project Variable into it.
Instead of using //gub-beratercard/mat-card[contains(., 'Jonathan')], I want to replace 'Jonathan" with a variable from my project.
I tried to use //gub-beratercard/mat-card[contains(., 'Project.Variables.ConsultantName')], with and also without quotes around the variable, but with no success.
Could you please help me find out how to place a variable into this Xpath expression?
Thanks!
Hi,
Just concatenate your template XPath string with the value stored in the variable.
E.g.:
var strXPath = aqString.Format("//gub-beratercard/mat-card[contains(., '%s')]", Project.Variables.ConsultantName);
And I agree with Marsha: try to avoid XPath in TestComplete unless you are considering cross-platform testing.