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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.