Exemple #1
0
        public static void Main()
        {
            try
            {
                using (IEngine engine = EngineFactory.Create(new EngineOptions.Builder().Build()))
                {
                    Console.WriteLine("Engine created");

                    using (IBrowser browser = engine.CreateBrowser())
                    {
                        Console.WriteLine("Browser created");

                        browser.Navigation.LoadUrl("http://www.google.com")
                        .Wait();
                        // Inserts "TeamDev DotNetBrowser" text into Google Search field.
                        browser.MainFrame.Execute(EditorCommand.InsertText("TeamDev DotNetBrowser"));
                        // Inserts a new line into Google Search field to simulate Enter.
                        browser.MainFrame.Execute(EditorCommand.InsertNewLine());

                        Thread.Sleep(3000);
                        // The page will now contain search results.
                        Console.WriteLine("Page contents:");
                        Console.WriteLine(browser.MainFrame.Document.DocumentElement.InnerText);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Press any key to terminate...");
            Console.ReadKey();
        }