We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

vb.net automate google website?

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
2
Contributors
2
Replies
1 Day
Discussion Span
1 Year Ago
Last Updated
3
Views
lasalle
Newbie Poster
1 post since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

ashishgh
Newbie Poster
6 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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
ashishgh
Newbie Poster
6 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0601 seconds using 2.69MB