我在watin中使用正则表达式。在watin中使用正则表达式
我有这样的:ie.Button(Find.ByName(new Regex(input))).Click();
但我不想点击第二个或第三个按钮匹配,而不是第一个。
我该怎么做?
我在watin中使用正则表达式。在watin中使用正则表达式
我有这样的:ie.Button(Find.ByName(new Regex(input))).Click();
但我不想点击第二个或第三个按钮匹配,而不是第一个。
我该怎么做?
试试这个:
ie.Button(Find.ByName(new Regex(input)) && Find.ByIndex(1 /* or 2 */)).Click();
试试这个:
ButtonCollection buttonCol = ie.Buttons;
buttonCol = buttonCol.Filter(Find.ByName(new Regex(input)));
buttonCol[1].Click();
buttonCol[2].Click();
了很多次,我觉得有必要选择高于第一回是因为有上查找过少预选赛。由*()构造。你可以尝试写出你自己的例子,这对你的特殊情况更有意义。
例如LINQ查询:
var buttons = from e in browser.Buttons
where e.Name == "Test" &&
e.Text == "Button1"
select e;
像这样的东西可以让你想要什么,你只选择。它还为您提供了一种快速检查计数的方法,使用.ToList()@结束它。或者使用下面的foreach循环来完成所需的操作。