Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 美元符号和{}作为定位器c是什么意思#_C#_Selenium Webdriver - Fatal编程技术网

C# 美元符号和{}作为定位器c是什么意思#

C# 美元符号和{}作为定位器c是什么意思#,c#,selenium-webdriver,C#,Selenium Webdriver,嗨,我不明白带$sign的定位器和大括号{name}中的名称。我的想法对吗?通过这种方式,您可以将定位器用作IList,也可以用作非IList。这是定位器: public IList ResultByName(字符串名称)=>dr.FindElements(By.Id($“//div[text()='{name}']) 然后在代码段中使用它: IList<IWebElement> list = _regRep.ResultByName(emailID); int actualCoun

嗨,我不明白带$sign的定位器和大括号{name}中的名称。我的想法对吗?通过这种方式,您可以将定位器用作IList,也可以用作非IList。这是定位器:

public IList ResultByName(字符串名称)=>dr.FindElements(By.Id($“//div[text()='{name}'])

然后在代码段中使用它:

IList<IWebElement> list = _regRep.ResultByName(emailID);
int actualCount = list.Count;
Assert.AreEqual(1, list.Count, "Only one user should match email " + emailID);
IList list=\u regremp.ResultByName(emailID);
int actualCount=list.Count;
Assert.AreEqual(1,list.Count,“只有一个用户应该匹配email”+emailID);
这其中存在一个缺陷,因为即使表中有一个
emailID
,它仍然给出了一个0的计数,这不是预期的值?

这是一个允许您将表达式添加到字符串中的值:

var myValue = "interpolate";
var interpolatedText = $"The dollar sign allows you to {myValue} text and literal C# expressions.";

它是在C#6.0中引入的,允许您避免使用
String.Format

这是一个名为。美元符号不是字符串本身的一部分,也不是特定于选择器的任何东西。
By.Id($“//span[text()[contains(,“{name}')]])
我猜这是一个错误,既然它看起来不像一个ID。为什么list.count不等于1,因为它在表中清晰可见?我使用了这个定位器,现在它可以工作了
public IList ResultByName(string name)=>dr.FindElements(By.XPath(//div[@class='vt-list-view-cell vt-list-view-cell_ubody vt list-view-cell-overflow'])[3][text()=“+name+”]”);