william king

william king

  • NA
  • 2
  • 2.9k

select a random link from google

Oct 23 2013 8:34 PM
I Have an application that has a text box and a button and when you click the button it open up Ie and Google and searches for what was typed into the text box. but i need it to than select a random link from the generated results every time. Anyone know how to do this? Here is the code i have so far 

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

                

                



              

            }
        }
    }
}


Answers (1)