简体   繁体   English

如何在 Playwright C# 的选择器中使用变量?

[英]How to use variables in selector in Playwright C#?

So we are validating the text present in our site using the excel sheet.因此,我们正在使用 excel 表验证我们网站中存在的文本。

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#?有没有办法在 C# 的选择器中附加变量?

这应该这样做:

ILocator service17 = page.Locator("//span[text()=ServiceName" + ServiceName + "]");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM