Sei sulla pagina 1di 9

Technical Note 551: Automatic Generation of LoadRunner Scripts from QTP Scripts

Last Modified: Area(s): Release(s): Database(s): App Server OS(s): Latest release tested against: Keywords: 11 August 2004 System Administration V7 (Enterprise), V7 (Professional) All Supported Databases All Supported Platforms V7 (Enterprise) Test, Testing, Load Testing, Auto Generation, QTP, LoadRunner, Mercury

Notice Below are the requirements necessary in order to successfully implement the information in this Technical Note: 1. The instructions in this Technical Note can be used for generating load test scripts from functional test scripts only in the case where the functional test tool is Mercury Interactives QuickTest Professional (QTP), version 6.5 and the load test tool is Mercury Interactives LoadRunner, version 7.8. 2. Additionally, this Technical Note is applicable only if you have appropriately licensed the Siebel Test Automation module, version 7.7 from Siebel Systems. For more information about Siebel Test Automation, refer to Siebel Bookshelf version 7.7 > Testing Siebel eBusiness Applications > Automating Load Tests. 3. Java Runtime Environment (JRE) version 1.4 or later must be installed on the machine where the AutoGenerate tool will be executed. The AutoGenerate tool is provided as part of this Technical Note, but JRE has to be obtained and installed separately. Background LoadRunner scripts are often very fragile and tend to work only in the same environment where the scripts were created. Environment changes, changes to the Siebel repository, schema changes, etc., often require a re-recording of the scripts. Such frequent re-recording not only increases the cost of load testing, but also poses a significant barrier to conducting more frequent load testing with realistic test scenarios. The fragility of the scripts is attributable to the fact that the scripts are created by essentially capturing the HTTP traffic between the browser running the Siebel application and the web server. Performance and scalability requirements expected of the load test tool mandate that the scripts be represented in a format that does not require multiple layers of abstraction during play back. On the other hand, Siebel Systems has made significant investments in the area of test automation to enable creating of robust and durable functional test scripts that continue to work across environments, languages and customized versions of Siebel eBusiness Applications. This Technical Note provides instructions to bridge this gap in durability (described above) by enabling automatic generation of load test scripts (LoadRunner scripts) from functional test scripts (QTP scripts). The idea is to leverage customers investments in functional test scripts, taking advantage of the durability and robustness of the QTP scripts, to automatically generate

page 1 of 9

Technical Note 551: Automatic Generation of LoadRunner Scripts from QTP Scripts

LoadRunner scripts, thereby reducing the cost of load testing Siebel applications and enabling expanded load testing with more realistic scenarios. Summary The process of generating LoadRunner scripts from QTP scripts is summarized in the diagram below:

Siebel Correlation Library is a product that facilitates automatic correlation of load test scripts. This product is a part of the Siebel Test Automation product line released as part of Siebel version 7.7. AutoGenerate is a post-processing tool provided as part of this Technical Note that inserts transaction boundaries into a LoadRunner script and rearranges the script into different Actions as specified in the QTP script. Test Script* in the above diagram refers to the LoadRunner script with the appropriate transaction boundaries inserted. The script is also organized into various Actions as specified in the QTP script.

Overview The starting point is a QTP script developed in conjunction with Siebel Test Automation. The user then manually inserts lines of code (calls to subroutines supplied as part of this Technical Note) to represent transaction boundaries and action definitions. Transactions and Actions (often referred to in this Technical Note) are part of LoadRunner terminology. Transactions represent units of actions for which performance characteristics are measured, monitored, and analyzed. An Action

page 2 of 9

Technical Note 551: Automatic Generation of LoadRunner Scripts from QTP Scripts

is comprised of one or more transactions and represents a unit of iteration during a load test. There are two special action types, vuser_init and vuser_end, each of which gets executed only once during a load test per virtual user. All other actions get executed as many times as the number of iterations specified for the load test. The subroutine calls manually inserted into the QTP script result in ping commands being sent to the server that represent: The start of an action with the action name Beginning of a transaction with the transaction name End of a transaction with the transaction name

In each case, the web server responds with an OK message which is simply ignored. However, the ping commands have to be sent from a browser different from the one running the Siebel application. The ping commands appear in the HTTP traffic which gets captured by LoadRunner. The AutoGenerate utility (supplied with this Technical Note) then performs post-processing on the LoadRunner script to identify and replace the ping commands with lr_start_transaction and lr_end_transaction calls that identify a transaction. The AutoGenerate utility also splits up the LoadRunner script into different .c files based on the action definitions in the QTP script. Steps To Auto-Generate LoadRunner Scripts from QTP Scripts Follow the steps below to auto generate LoadRunner scripts from QTP scripts. 1. Based on the test scenario, record a corresponding QTP script. NOTE: Subsequent steps are also applicable even when starting with existing QTP scripts, as long as the scripts were recorded using QTP 6.5 in conjunction with Siebel Test Automation version 7.7. 2. A set of subroutines are provided in the section titled 'Auto Generate Subroutines' below. Copy those subroutines into your QTP script. 3. Modify the resulting QTP script as described in the steps below: (Note that each of the calls in the steps below represents a call to a subroutine in the Auto Generate Subroutines section). a. Add the second browser to the QTP object repository. The easiest way to do this is to scroll to the very end of the script, start recording, open two browsers, and enter any valid URL in the second browser. b. Declare two variables named Server and Application and set these variables to the values of the web server and the application name that you will be recording against, respectively. The sample QTP script in the section titled 'Sample QTP Script with Transaction Boundaries and Action Definitions' below demonstrates this. c. Place a call to the Init subroutine immediately following the variable declarations in the above step by inserting a line with the text Init ( ) (without the quotation marks). To alter the HTTP traffic to capture transaction boundaries and action definitions, ping commands are sent to the server, and an OK response is received for each such ping request. The ping command has to be sent from a separate browser than the one running the Siebel application. The Init subroutine handles the task of creating the separate browser window to send the ping commands and capturing the resulting OK responses so that the main browser running the Siebel application is not affected.

page 3 of 9

Technical Note 551: Automatic Generation of LoadRunner Scripts from QTP Scripts

d. To represent the beginning of an action, insert a line of code with the format: CreateNewAction <ActionName>. There is no command to explicitly end an action definition. The start of a new action implicitly denotes the end of the previous action, if any. i. vuser init, which is a special type of action in LoadRunner is defined using the following line of code: CreateNewAction vuser_init vuser_end, which is a special type of action in LoadRunner is defined using the following line of code: CreateNewAction vuser_end

ii.

e. Insert lines of code to represent the beginning and end of transactions. i. To represent the start of a transaction, insert a line of code with the format: StartTransaction <Transaction_Name> To represent the end of a transaction, insert a line of code with the format: EndTransaction <Transaction_Name>

ii.

4. Save the edited QTP script (the script now contains transaction and action definitions). 5. Start the Virtual User (VU) Generator module of LoadRunner in the Record mode. Ensure that the recording session starts at the URL "about:blank". 6. Execute the QTP script. 7. Once the QTP script completes, stop recording from the VU Generator. At this point, LoadRunner integrates with the Siebel Correlation Library to automatically correlate the script. 8. At this point, the LoadRunner script is almost ready, except that the transaction and action boundaries are missing from the script. Save the LoadRunner script, and close or exit out of the Virtual User Generator. NOTE: Virtual User Generator must be closed before running the AutoGenerate utility. 9. Ensure that the AutoGenerate tool is available on the same machine as the LoadRunner installation used in the above steps. Also ensure that AutoGenerate.exe is in the system path. 10. Open a command window and navigate to the directory where the LoadRunner script is saved. Execute AutoGenerate.exe. The results should indicate that the post processing was completed successfully to insert the transaction boundaries and rearrange the script into different actions as specified in the QTP script. The script is now ready for playback. However, any user key parameterization still needs to be handled manually before the script can be played back multiple times for multiple virtual users. Auto Generate Subroutines Sub Init () while (not Browser("Browser").Exist) ' We are waiting for the browser to come up from which the ping commands will be issued. Wait 1 wend

page 4 of 9

Technical Note 551: Automatic Generation of LoadRunner Scripts from QTP Scripts

SystemUtil.Run "iexplore.exe","about:blank","C:\\Program Files\\Internet Explorer\\" while (not Browser("Browser_2").Exist) Wait 1 wend Browser("Browser_2").Sync Extern.Declare micInteger, "ShowWindow", "ShowWindow", micHwnd, micInteger "user32.dll",

hwnd = Browser("Browser_2").GetROProperty("hWnd") Extern.ShowWindow hwnd, 6 'SW_MINIMIZE End Sub

Sub Destroy () Browser("Browser_2").Close End Sub

Sub CreateNewAction (ActionName) Browser("Browser").Sync Browser("Browser_2").Navigate "http://" & Server & "/" & Application & "/start.swe?SWECmd=Ping&_sn=&SWETS=&SWEHo=" & Server & "&Action=NewAction&Name=" & ActionName Wait 1 Browser("Browser_2").Sync End Sub

Sub StartTransaction (TransName) Browser("Browser").Sync Browser("Browser_2").Navigate "http://" & Server & "/" & Application & "/start.swe?SWECmd=Ping&_sn=&SWETS=&SWEHo=" & Server & "&Action=StartTransaction&Name=" & TransName Wait 1 Browser("Browser_2").Sync Services.StartTransaction TransName End Sub

Sub EndTransaction (TransName) Browser("Browser").Sync Services.EndTransaction TransName

page 5 of 9

Technical Note 551: Automatic Generation of LoadRunner Scripts from QTP Scripts

Browser("Browser_2").Navigate "http://" & Server & "/" & Application & "/start.swe?SWECmd=Ping&_sn=&SWETS=&SWEHo=" & Server & "&Action=EndTransaction&Name=" & TransName Wait 1 Browser("Browser_2").Sync End Sub Sample QTP Script with Transaction Boundaries and Action Definitions Below are some guidelines to follow regarding the sample QTP script: Please note that the script below is meant only as a reference and cannot be executed as-is. For brevity, the subroutines are not included again in this section. However, they should be part of the QTP script that will be used to automatically generate the LoadRunner script. The user must start a LoadRunner recording session before starting this script. The recording session must start at the URL "about:blank"

'Initialization Server = "sdcdl360i131" Application = "fins_enu" Init() 'Login CreateNewAction "vuser_init" StartTransaction "Bring up Login Page" Browser("Browser").Navigate "http://" & Server & "/" & Application & "/start.swe?SWECmd=AutoOn" EndTransaction "Bring up Login Page" StartTransaction "Login" Browser("Browser").Page("Siebel Financial_2").WebEdit("_SweUserName").Set "SADMIN" Browser("Browser").Page("Siebel Financial_2").WebEdit("_SwePassword").Set "SADMIN" Browser("Browser").Page("Siebel Financial_2").Image("LoginButton").Click Wait 2 ' Ensure the sync in EndTransaction will work EndTransaction "Login" 'Action for Iter = 1 to 2 CreateNewAction "Action" & CStr(Iter)

page 6 of 9

Technical Note 551: Automatic Generation of LoadRunner Scripts from QTP Scripts

StartTransaction "Goto Contacts Screen" SiebApplication("Siebel Financial").SiebPageTabs("PageTabs").GotoScreen "Service Request Screen" EndTransaction "Goto Contacts Screen" StartTransaction "Goto Contacts Screen - Visible Contact List View" SiebApplication("Siebel Financial").SiebPageTabs("PageTabs").GotoView "Personal Service Request List View" EndTransaction "Goto Contacts Screen - Visible Contact List View" StartTransaction "Drilldown on Service Request" SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("My Service Requests").SiebApplet("Service Requests").SiebList("List").DrillDownColumn "SR Number",0 EndTransaction "Drilldown on Service Request" StartTransaction "Goto Service Request Screen - Related SRs View" SiebApplication("Siebel Financial").SiebToolbar("HIMain").Click "SiteMap" Browser("Siebel Financial").Page("Siebel Financial").Frame("View Frame").Link("Related SRs").Click 'SiebApplication("Siebel Financial").SiebScreen("Service").SiebScreenViews("ScreenViews").Goto "Service Request Related SR View","L3" EndTransaction "Goto Service Request Screen - Related SRs View" StartTransaction "Goto Service Request Screen - Solution View" SiebApplication("Siebel Financial").SiebScreen("Service").SiebScreenViews("ScreenViews").Goto "Service Request Solution View","L3" EndTransaction "Goto Service Request Screen - Solution View" StartTransaction "Click New to Start a Query for a New Solution" SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("Service Request").SiebApplet("Solutions").SiebButton("New").Click EndTransaction "Click New to Start a Query for a New Solution" StartTransaction "Click Go to Query for All Solutions" SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("Service Request").SiebApplet("Add Solutions").SiebButton("Go").Click EndTransaction "Click Go to Query for All Solutions" StartTransaction "Click New to Create a New Solution" SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("Service Request").SiebApplet("Add Solutions").SiebButton("New").Click EndTransaction "Click New to Create a New Solution" StartTransaction "Save the New Solution"

page 7 of 9

Technical Note 551: Automatic Generation of LoadRunner Scripts from QTP Scripts

SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("Service Request").SiebApplet("Solutions").SiebList("List").SiebText("Name").Set Text "NewName" & RandStr(5) ' Make a unique user-key. SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("Service Request").SiebApplet("Solutions").SiebList("List").SiebTextArea("FAQ"). SetText "This is a FAQ." SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("Service Request").SiebApplet("Solutions").SiebList("List").SiebTextArea("Descri ption").SetText "This is a Description." SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("Service Request").SiebApplet("Solutions").SiebList("List").SiebTextArea("Commen ts").SetText "This is a Comment." SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("Service Request").SiebApplet("Solutions").SiebMenu("Menu").Select "WriteRecord" EndTransaction "Save the New Solution"

StartTransaction "Goto Service Request Screen - Activities View" SiebApplication("Siebel Financial").SiebPageTabs("PageTabs").GotoView "Personal Service Request List View" EndTransaction "Goto Service Request Screen - Activities View" StartTransaction "Update Service Request Status" 'Toggle between Pending and Open Status. Status = SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("My Service Requests").SiebApplet("Service Requests").SiebList("List").SiebPicklist("Status").ActiveItem if (Status = "Pending") then Status = "Open" else Status = "Pending" end if SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("My Service Requests").SiebApplet("Service Requests").SiebList("List").SiebPicklist("Status").Select Status EndTransaction "Update Service Request Status" StartTransaction "Save Service Request" SiebApplication("Siebel Financial").SiebScreen("Service").SiebView("My Service Requests").SiebApplet("Service Requests").SiebMenu("Menu").Select "WriteRecord" EndTransaction "Save Service Request" next 'Logout

page 8 of 9

Technical Note 551: Automatic Generation of LoadRunner Scripts from QTP Scripts

CreateNewAction "vuser_end" StartTransaction "Logout" SiebApplication("Siebel Financial").SiebMenu("Menu").Select "File\\File - Logout" EndTransaction "Logout" 'Termination Destroy() Browser("Browser").Close

AutoGenerate.exe File The AutoGenerate.exe file is contained within the zip file that can be downloaded from this link: technote551-1_AutoGenerate.zip

page 9 of 9

Potrebbero piacerti anche