public IWebElement GetButtontoClick(IWebElement prObj, string propName, string propVlu)
{
IWebElement btnToClick = null;
try
{
//get the list of all buttons in the prObj
IList<IWebElement> btnlList = prObj.FindElements(By.ClassName("xyz"));
//iterate through each button element and find the button you want to click
for (int i = 0; i < btnlList.Count; i++)
{
IWebElement btn = btnlList[i];
var btnPropValue = ((IJavaScriptExecutor)DriverContext.Driver).ExecuteScript("return arguments[0]."+ propName+"; ", btn);
if (propVlu == btnPropValue.ToString())
{
Console.WriteLine("You have found the button you want to click");
btnToClick = btn;
break;
}
}
}
catch (Exception)
{
throw;
}
return btnToClick;
}
首先获取所有这些按钮所在的父容器的引用,然后必须通过向标识要单击的按钮的方法传递唯一参数来获取要单击的按钮引用
如何调用此方法
^{pr2}$希望这能奏效。在
相关问题 更多 >
编程相关推荐