FindElementsByTagName() публичный Метод

Finds a list of elements that match the DOM Tag supplied
public FindElementsByTagName ( string tagName ) : ReadOnlyCollection
tagName string DOM tag Name of element being searched
Результат ReadOnlyCollection
Пример #1
0
        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();
        }