Retrieving data from State Information

dwhalendwhalen Posts: 4
edited October 8, 2004 10:51AM in ANTS Load
I want to create a script to pull data from a pool of users. Unfortunately the details on how to do this are not well presented in your help file. So I took a shot at it using what information was available and a post in this forum.

I have been trying to duplicate the Login script posted by another user. I created a script called Login (text below), added 2 columns for State Information (account and password), declared the variables in the script and replaced the actual text with the account and password variables in AddPostData. To test it, I only entered one row in State Information for as single user. During the test I get the following error:

"An unhandled exception has occured in your application...

Overflow error"

I click continue and the test runs successfully but the counter screen is replaced by a big red X. Can you please let me know if I'm doing this correctly or provide more detailed instructions.

Thanks!
Dave

Here's the script:

Imports System
Imports RedGate.Ants.Engine

Public Class Login
Inherits Control.VirtualClient

Protected Overrides Sub Run()
' Script created with Internet Explorer on 10/7/2004 12:22:52 PM

Dim account As String = StateInformation.Get("account")
Dim password As String = StateInformation.Get("password")

' Random pause of between and 1 and 2 seconds
' (Remove this line if you want all scripts to start at the same time)
RandomSleep(1000, 2000)

WebClient.HttpRequest.ProtocolVersion = "HTTP/1.1"
BeginPage("http://xxx.com/")
WebClient.HttpRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; FunWebProducts; .NET CLR 1.1.4322; .NET CLR 1.0.3705)"
WebClient.Get("http://xxx.com/")
WebClient.Get("http://xxx.com/login.aspx")
WebClient.Get("http://xxx.com/Images/Icons/blue_xxx_logo_tagline.gif")
WebClient.Get("http://xxx.com/Images/Buttons/site_feedback.gif")
WebClient.Get("http://xxx.com/Images/Buttons/btnCustServ.jpg")
WebClient.Get("http://xxx.com/Images/General/graybar.jpg")
WebClient.Get("http://xxx.com/Images/General/topbar.jpg")
WebClient.Get("http://xxx.com/Images/Buttons/btnLogin.jpg")
WebClient.Get("http://xxx.com/Images/Buttons/btnHelp.jpg")
WebClient.Get("http://xxx.com/Images/General/3075FEcurve1.jpg")
WebClient.Get("http://xxx.com/Images/Buttons/btn_submit.gif")
WebClient.Get("http://xxx.com/Images/General/LeftNavLogo.jpg")
WebClient.Get("http://xxx.com/Images/Buttons/btnForgotPassword.jpg")
WebClient.Get("http://xxx.com/Images/General/goldBar.jpg")
WebClient.HttpRequest.Pragma = "no-cache"
WebClient.HttpRequest.AddPostData("__VIEWSTATE", WebClient.ViewState, False)
WebClient.HttpRequest.AddPostData("txtAccount", account, False)
WebClient.HttpRequest.AddPostData("txtPassword", password, False)
WebClient.HttpRequest.AddPostData("btnSubmit.x", "56", False)
WebClient.HttpRequest.AddPostData("btnSubmit.y", "11", False)
WebClient.Post("xxx.com/login.aspx")
WebClient.Get("xxx.com/default.aspx")
WebClient.HttpRequest.Pragma = Nothing
WebClient.Get("http://xxx.com/Scripts/browser_close.js")
WebClient.Get("http://xxx.com/Images/Icons/cart1.gif")
WebClient.Get("http://xxx.com/Images/Buttons/btnLogout.jpg")
WebClient.Get("http://xxx.com/Images/Buttons/btnUserProfile.jpg")
WebClient.Get("http://train.xxx.com/Images/General/spacer.gif")
WebClient.HttpRequest.Pragma = "no-cache"
WebClient.HttpRequest.AddPostData("__EVENTTARGET", "", False)
WebClient.HttpRequest.AddPostData("__EVENTARGUMENT", "", False)
WebClient.HttpRequest.AddPostData("__VIEWSTATE", WebClient.ViewState, False)
WebClient.HttpRequest.AddPostData("ucHeader%3AucHeaderMenu%3AbtnLogout.x", "37", False)
WebClient.HttpRequest.AddPostData("ucHeader%3AucHeaderMenu%3AbtnLogout.y", "7", False)
WebClient.Post("http://xxx.com/default.aspx")
WebClient.Get("http://xxx.com/login.aspx")
EndPage("http://xxx.com/")
' End of page 1 contains 23 request(s).

' End of script contains 1 page(s).


End Sub
End Class

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi David,

    Do the usernames and passwords have 'special' characters like spaces, ampersands, or plus signs? If they do, you may want to change the URL encoding option in the AddPostData method. This will replace special characters with something webserver-friendly. For instance:

    WebClient.HttpRequest.AddPostData("txtAccount", "Brian Donahue", True) will post Brian%20Donahue to the web server. WebClient.HttpRequest.AddPostData("txtAccount", "Brian Donahue", False) will post the string exactly as it is, space and all, and may cause an error.
This discussion has been closed.