本文整理汇总了C#中OpenQA.Selenium.Remote.RemoteWebDriver.FindElementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:C# RemoteWebDriver.FindElementsByTagName方法的具体用法?C# RemoteWebDriver.FindElementsByTagName怎么用?C# RemoteWebDriver.FindElementsByTagName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Remote.RemoteWebDriver
的用法示例。
在下文中一共展示了RemoteWebDriver.FindElementsByTagName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
// find the test application
Console.WriteLine("Finding Test App");
string appPath = _GetTestAppPath();
Console.WriteLine("Using Test App @ \"" + appPath + "\"");
// set up the remote web driver
Console.WriteLine("Connecting to Appium server");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("browserName", "iOS");
capabilities.SetCapability("platform", "Mac");
capabilities.SetCapability("version", "6.0");
capabilities.SetCapability("app", appPath);
RemoteWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
// enter random numbers in all text fields
Console.WriteLine("Entering addends");
List<int> addends = new List<int>();
Random randomNumberGenerator = new Random();
var elements = driver.FindElementsByTagName("textField");
foreach(var element in elements)
{
int randomNumber = randomNumberGenerator.Next(0,10);
element.SendKeys(randomNumber.ToString());
addends.Add(randomNumber);
}
// calculate the expected result
int expectedResult = 0;
foreach(int i in addends)
expectedResult += i;
Console.WriteLine("Submitting the form");
// submit for computation
var buttons = driver.FindElementsByTagName("button");
buttons[0].Click();
// validate the computation
var staticTexts = driver.FindElementsByTagName("staticText");
int actualResult = int.Parse(staticTexts[0].Text);
bool pass = expectedResult == actualResult;
_LogWithColor(pass, "EXPECTED: " + expectedResult.ToString() + " ACTUAL: " + actualResult.ToString());
// shutdown
driver.Quit();
}