2 methods for load test with scripting, confused about which one to use..
Until now, I have seen two method to handle Load test with scripting and I am confused which one I need to follow ?
1.Method
This method is the example used in Advanced Load Test with scripting help page. It makes everything in script including running Internet Explorer.
This example deals a very simple page and does not handle much user or parametrization from a database.
2.Method
And the other method which uses recorded tasks request, dealing with 4 vuser.
Both of the examples does not deal with running test with much user and parametrisation. The codes are written below.
Please any idea will be helpful.
Best Regards.
--------------
Code for the 1.Method
function Main()
{
var p, w, w1, Pg;
Options.Web.TreeModel = "Tree";
// Obtain the browser process and the web page window
p = Sys.Process("IEXPLORE");
w = p.IEFrame(0).Window("Shell DocObject View").Window("Internet Explorer_Server");
// Go to the Google search page
Pg = w.ToURL("http://www.google.com/");
// Enter "TestComplete" in the search field
w1 = Pg.Form("f").Table(0).Cell(0, 1);
w1.Textbox("q").value = "TestComplete";
w1.SubmitButton("btnG").Click();
// Wait until the results are loaded: "http://www.google.com/search?hl=en&q=TestComplete&btnG=Google+Search"
w.Wait();
Pg = w.Page("http://www.google.com/search*");
// Click the first link
Pg.Panel("res").Panel(0).Panel(0).Link(0).Click();
}
----------------------------------------------------
Code for the 2.Method
function TestLoginLogout()
{
var TestInstance, HTTPTask, request, VUser
TestInstance = LoadTesting.CreateTestInstance("Test")
for (i = 0; i < 5 ;i++) {
HTTPTask = LoadTesting.HTTPTask("TaskLoginLogout1")
request = HTTPTask.Connection(1).Request(5)
if (i = 0) {
request.BodyVariables.Item("UserName") = "vuser1@hotmail.com"
request.BodyVariables.Item("Password") = "123465" }
if (i = 1) {
request.BodyVariables.Item("UserName") = "vuser1@hotmail.com"
request.BodyVariables.Item("Password") = "123456" }
if (i = 2) {
request.BodyVariables.Item("UserName") = "vuser1@hotmail.com"
request.BodyVariables.Item("Password") = "123456" }
else
if (i = 4) {
request.BodyVariables.Item("txtUserName") = "vuser1@@hotmail.com"
request.BodyVariables.Item("txtUsrPassword") = "123456" }
// create a virtual user and add it to the test instance
VUser = LoadTesting.CreateVirtualUser("VU_" & i)
VUser.Task = HTTPTask
VUser.TestInstance = TestInstance
}
}