0

So we are validating the text present in our site using the excel sheet.

for(int i = 0; i < services.Count; i++)
{
    string ServiceName = ExcelFunction.getCellValue(filepath, TestContext.CurrentContext.Test.MethodName, "ServiceName", i);
    ILocator service17 = page.Locator("//span[text()=ServiceName]");// here I want to append the ServiceName that I get from excel sheet to the selector.
}

Is there any way to append the variables in selectors in C#?

Etheraex
  • 508
  • 6
  • 17
Nalin
  • 57
  • 1
  • 11

1 Answers1

2

This should do it:

ILocator service17 = page.Locator("//span[text()=ServiceName" + ServiceName + "]");
Christian Baumann
  • 3,188
  • 3
  • 20
  • 37