1,105,226 Community Members

vb.net automate google website?

Member Avatar
lasalle
Newbie Poster
1 post since Oct 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I'm trying to automate browser at google website, http://www.google.com/finance/option_chain?q=nflx.

There are several expiration dates in the drop down list. If you choose one, the option table below is updated accordingly. The website script is listed below.

<div id="expirations" class="id-expirations float sfe-break-left">
<select>
<option value="0">Jan 21, 2012</option>
<option value="1">Jan 27, 2012</option>
<option value="2">Feb 18, 2012</option>
<option value="3">Mar 17, 2012</option>
<option value="4">Jun 16, 2012</option>
<option value="5">Jan 19, 2013</option>
<option value="6">Jan 18, 2014</option>
</select>
</div>

Here is my VB 2008.net code. It can find the drop down list, but even I used SetAttribute, the website is not updating. For example the code choose the last expiration date, but the option table still shows the first expiration table. How should I update the option table in VB.net? Anyone can help? Thanks

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        If Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
            Dim StrikeExpiry As HtmlElement
            StrikeExpiry = WebBrowser1.Document.GetElementById("expirations")
            TextBox2.Text = StrikeExpiry.All.Count - 1 'the number of expiry
            'TextBox2.Text = StrikeExpiry.InnerText

            For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("select")
                element.SetAttribute("value", StrikeExpiry.All.Count - 2)
            Next

        End If

    End Sub
Member Avatar
ashishgh
Newbie Poster
6 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Use Selenium IDE to automate such tasks(It's a plugin for firefox) ,you would never require to write this much senseless code and break your head.

Member Avatar
ashishgh
Newbie Poster
6 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Record a selenium macro,before running it just add a command to set execution interval belween each dorop down click as Command:setSpeed and target:6000 leave value: as blank....see attachment. Run it

Attachments selenium.png 27.98KB
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: