Forum Discussion

rastech1's avatar
rastech1
Occasional Contributor
14 years ago

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


}


}

3 Replies

  • Hi Rasim,



    The first script you provided is for functional testing of web applications. It works with your web browser and simulates mouse clicks and keystrokes with the web browser's objects. Please see the Testing Web Applications help topic for more information.



    The second script is for HTTP load testing. It does not interact with your browser - TestComplete acts as a web browser in this case, and this script works with HTTP requests and responses instead of web page elements. So, the two scripts are for two absolutely different testing types which work with absolutely different entities. As for the testing type you need to choose, the following information should help you with that. 



    There are two plug-ins in TestComplete: the HTTP Load Testing plug-in and Network Suite plug-in. 



    The first allows you to test client-server applications that communicate using HTTP or Secure HTTP. TestComplete emulates up to 300 virtual users on each computer involved in testing. If you are interested in this approach, please read the Load Testing - Overview help topic - it includes links to other help topics.



    The second plug-in performs distributed testing of the server application through the GUI of a number of client applications. You can simulate as many users as many computers are involved in the testing process: the client application will be launched on each computer and the script on the master machine will control activity of every client. Please see the Distributed Testing topic of the help system for details.
     



    Also, please see the following pages for more information:


    Distributed Testing With TestComplete

    Can I perform distributed testing with TestComplete?
  • rastech1's avatar
    rastech1
    Occasional Contributor
    Thank you for the information.



    I know these codes for functional testing, What I need no know that, if I want to use these piece of scripts in order to make Laod test, which approach should I follow ?



    Regards,

  • Hi Rasim,





    If you want to simulate multiple users working with the application's GUI via a number of web browsers, you need to use the Network Suite feature. You can use a single TestComplete instance to create and debug your test and a number of TestExecute instance to run the test on different machines.