Forum Discussion

cristiandiaconu's avatar
cristiandiaconu
New Contributor
5 years ago

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 vari...
  • AlexKaras's avatar
    5 years ago

    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.