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
}
}
}
}
Re: WPF with WatiN plug in. need to open up IE and go to google