本文整理汇总了C#中IPage.GetLocatorOfWebElement方法的典型用法代码示例。如果您正苦于以下问题:C# IPage.GetLocatorOfWebElement方法的具体用法?C# IPage.GetLocatorOfWebElement怎么用?C# IPage.GetLocatorOfWebElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPage
的用法示例。
在下文中一共展示了IPage.GetLocatorOfWebElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteScript
public static void ExecuteScript(IPage pageObject,string xlPath, string sheetName)
{
var totalRow = ExcelReaderHelper.GetTotalRows(xlPath, sheetName);
for (var i = 2; i < totalRow; i++)
{
var action = ExcelReaderHelper.GetCellValue(xlPath, sheetName, i, 1);
var webEle = ExcelReaderHelper.GetCellValue(xlPath, sheetName, i, 2);
if ((webEle == string.Empty) && (action == string.Empty))
break;
if (webEle == string.Empty)
continue;
var locator = pageObject.GetLocatorOfWebElement(webEle);
Console.WriteLine("Action {0}, WebElement {1}, Locator {2} ",action,webEle,locator);
switch (action)
{
case "SendKeys":
{
var text = ExcelReaderHelper.GetCellValue(xlPath, sheetName, i, 3);
TextBoxHelper.TypeInTextBox(locator,text);
}
break;
case "ClearAndSendKeys":
{
var text = ExcelReaderHelper.GetCellValue(xlPath, sheetName, i, 3);
TextBoxHelper.ClearTextBox(locator);
TextBoxHelper.TypeInTextBox(locator, text);
}
break;
case "Click":
{
ButtonHelper.ClickButton(locator);
}
break;
case "ClickIfExist":
{
if (GenericHelper.IsElementPresentQuick(locator))
{
ButtonHelper.ClickButton(locator);
}
}
break;
case "Select":
{
var text = ExcelReaderHelper.GetCellValue(xlPath, sheetName, i, 3);
DropDownHelper.SelectByVisibleText(locator,text);
}
break;
case "SelectIndex":
{
var text = ExcelReaderHelper.GetCellValue(xlPath, sheetName, i, 3);
DropDownHelper.SelectByIndex(locator, Convert.ToInt32(text));
}
break;
case "WaitForEle":
{
var text = ExcelReaderHelper.GetCellValue(xlPath, sheetName, i, 3);
if (text == string.Empty)
{
GenericHelper.WaitForElement(locator);
}
else
{
GenericHelper.WaitForElement(locator, Convert.ToInt32(text));
}
}
break;
case "Sleep":
{
var text = ExcelReaderHelper.GetCellValue(xlPath, sheetName, i, 3);
Thread.Sleep(Convert.ToInt32(text));
}
break;
case "SelectFile":
{
var text = ExcelReaderHelper.GetCellValue(xlPath, sheetName, i, 3);
pageObject.FileUpload(text);
}
break;
case "AssertTitle":
{
var text = ExcelReaderHelper.GetCellValue(xlPath, sheetName, i, 3);
Assert.AreEqual(text, ObjectRepository.Driver.Title);
}
break;
case "PerformClick":
{
//.........这里部分代码省略.........