CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  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 01:30 AM. Reason: added code tags.

  2. #2
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

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

    [Moved Thread]
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

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
  •  





Click Here to Expand Forum to Full Width

Featured