WPF with WatiN plug in. need to open up IE and go to google
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: WPF with WatiN plug in. need to open up IE and go to google

Threaded View

  1. #1
    Join Date
    Oct 2013
    Posts
    11

    Exclamation WPF with WatiN plug in. need to open up IE and go to google

    I am making a WPF application in visual studio 2012 for desktop. that Has to use the WatiN plug in. And I have to have a text box and button (which I have), That when you type in the text box and click the button the app will launch IE and go to google and search for whatever you typed into the text box and automatically select a link from the list of search results and go to that page. It opens up IE and goes to google and types in what was in the text box into the search box but than the app closes. It doesnt search or select a link at random. Here is the code I have so far please help.


    Code:
    using WatiN.Core;
    
    namespace Search
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void Btn_Click(object sender, RoutedEventArgs e)
            {
                using (var browser = new IE("http://www.google.com"))
                {
                    browser.TextField(Find.ByName("q")).TypeText(_textBox.Text);
                    browser.Button(Find.ByName("btnG")).Click();
    
                    browser.WaitForComplete(5000);
    
                    System.Windows.Forms.SendKeys.SendWait("{ENTER}"); // presses search on the second screen
    
                    //browser.Button(Find.ById("gbqfb")/*.ByName("btnG")*/).Click();  // doesn't work
    
                }
            }
        }
    }
    Last edited by GremlinSA; November 7th, 2013 at 12:30 AM. Reason: added code tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center