Don Sartain

Don Sartain

  • NA
  • 15
  • 6.5k

C# Watin Get Google Search Results

Jan 21 2013 11:22 PM
I'm developing a basic app that will perform a Google search based on a text field value and then open a web page based on a given Google result. I have this working, but only on the first result. I can't get access to the remaining results.
 
In firebug, I see this code for the first three listings

<h3 class="r">
<a class="l"  önmousedown="return rwt(this,'','','','2','AFQjCNGm_Xkvwld9e7TYNqWga_fksOOKlA','','0CDUQFjAB','','',event)" href="http://www.ht-llc.com/">
HealthTech Solutions
Group
</a>
</h3>
 
<h3 class="r">
<a class="l"  önmousedown="return rwt(this,'','','','2','AFQjCNGm_Xkvwld9e7TYNqWga_fksOOKlA','','0CDUQFjAB','','',event)" href="http://www.ht-llc.com/">
HealthTech Solutions
Group
</a>
</h3>
 
<h3 class="r">
<a class="l"  önmousedown="return rwt(this,'','','','4','AFQjCNF9v26pz2xQuVtIciioX883AVShsA','','0CEgQFjAD','','',event)" href="http://4hts.com/">
</h3>

Because they each have a class of "l", I have the code set up to look for the href value of the links with class of "l".

string resultStats = browser.Element(Find.ByClass("l")).GetAttributeValue("href").ToString();
                          
                            //Display URL in text box
                            txtResults.Text = "Opening URL: " + resultStats;



How can I modify this to pull back all the results, or at least let me select a specific one other than the first?