Encog.Bot.Browse.WebPage.Find C# (CSharp) Method

Find() public method

Find the specified DocumentRange subclass in the contents list.
public Find ( Type c, int index ) : DocumentRange
c System.Type The class type to search for.
index int The index to search from.
return Encog.Bot.Browse.Range.DocumentRange
        public DocumentRange Find(Type c, int index)
        {
            int i = index;
            foreach (DocumentRange span in Contents)
            {
                if (span.GetType() == c)
                {
                    if (i <= 0)
                    {
                        return span;
                    }
                    i--;
                }
            }
            return null;
        }

Usage Example

Example #1
0
        public void TestFormGET()
        {
            var b = new Browser();

            b.Navigate(new Uri("http://www.httprecipes.com/1/7/get.php"));
            WebPage page = b.CurrentPage;

            Assert.IsTrue(page.Title.GetTextOnly().IndexOf("HTTP") != -1);
            var   form   = (Form)page.Find(typeof(Form), 0);
            Input input1 = form.FindType("text", 0);

            input1.Value = "New York";
            b.Navigate(form);
            page = b.CurrentPage;
            Assert.IsTrue(page.Title.GetTextOnly().IndexOf("HTTP") != -1);
        }