Thursday, May 31, 2012

All about LR function web_reg_save_param

Hi,
Lets talk about one of the most important function and important for correlation in HP Loadrunner.

This function registers a request to save dynamic data information to a parameter.

Syntax for C language:
int web_reg_save_param( const char *ParamName, <List of Attributes>, LAST ); 

Syntax for Java language:
int object.reg_save_param( String ParamName, String[] attributeList );  


Argument
Description
object
An expression evaluating to an object of type WebApi. Usually web for Java and Visual Basic. See also Function and Constant Prefixes.
ParamName
A null–terminated string indicating the name of the parameter to create.
List of Attributes
For details of each attribute, see List of Attributes.
Attribute value strings (e.g., "Search=all") are not case–sensitive.
LAST
A marker that indicates the end of the argument list.

The web_reg_save_param function is a Service function used for correlating HTML statements in Web scripts..

Note: (Service functions : Service Functions perform customization tasks, like setting of proxies, authorization information, user–defined headers and so forth. These functions do not make any change in the Web application context.
Many of the service functions specify run–time settings for a script. A setting that is set with a service function always overrides the corresponding setting set with the Run–time settings dialog box.)

General Information

web_reg_save_param is a registration type function. It registers a request to find and save a text string within the server response. The operation is performed only after executing the next action function, such as web_url.
web_reg_save_param is only recorded when correlation during recording is enabled (see VuGen's Recording Options). VuGen must be in either URL–based recording mode, or in HTML–based recording mode with the A script containing explicit URLs only option checked (see VuGen's Recording Options).
This function registers a request to retrieve dynamic information from the downloaded page, and save it to a parameter. For correlation, enclose the parameter in braces (e.g., "{param1}") in ensuing function calls which use the dynamic data. The request registered by web_reg_save_param looks for the characters between (but not including) the specified boundaries and saves the information that begins at the byte after the left boundary and ends at the byte before the right boundary.
If you expect leading and trailing spaces around the string and you do not want them in the parameter, add a space at the end of the left boundary, and at the beginning of the right boundary. For example, if the Web page contains the string, "Where and when do you want to travel?", the call:
web_reg_save_param("When_Txt", "LB=Where and ", "RB= do",LAST );
with a space after "and" and before "do", will result in "when" as the value of When_Txt. However,
web_reg_save_param("When_Txt", "LB=Where and", "RB=do",LAST );
without the spaces, will result in a value of " when ".
Embedded boundary characters are not supported. web_reg_save_param results in a simple search for the next occurrence after the most recent left boundary. For example, if you have defined the left boundary as the character `{` and the right boundary as the character `}', then with the following buffer c is saved:
          {a{b{c}
The left and right boundaries have been located. Since embedded boundaries are not supported, the `}' is matched to the most recent `{` appearing just before the c. The ORD attribute is 1. There is only one matching instance.
The web_reg_save_param function also supports array type parameters. When you specify ORD=All, all the occurrences of the match are saved in an array. Each element of the array is represented by the ParamName_index. In the following example, the parameter name is A:
web_reg_save_param("A", "LB/ic=", "Ord=All", LAST );
The first match is saved as A_1, the second match is saved as A_2, and so forth. You can retrieve the total number of matches by using the following term: ParamName_count. For example, to retrieve the total number of matches saved to the parameter array, use:
TotalNumberOfMatches=atoi(lr_eval_string("{A_count}"));
The following table indicates how to use the boundary parameters to save portions of the parameter string:

Portion of string to save to parameter
LB
RB
the entire string
empty
empty
a string delimited by boundaries
boundary
boundary
the beginning of a string until the first right boundary
empty
boundary
the last left boundary until the end
boundary
empty

This function is supported for all Web scripts, and for WAP scripts running in HTTP or Wireless Session Protocol (WSP) replay mode.
List of Attributes
  • Convert: The possible values are:
    HTML_TO_URL: convert HTML–encoded data to a URL–encoded data format
    HTML_TO_TEXT: convert HTML–encoded data to plain text format
    This attribute is optional.
  • IgnoreRedirections: If "IgnoreRedirections=Yes" is specified and the server response is redirection information (HTTP status code 300-303, 307), the response is not searched. Instead, after receiving a redirection response, the GET request is sent to the redirected location and the search is performed on the response from that location.
    This attribute is optional. The default is "IgnoreRedirections=No".
  • LB: The left boundary of the parameter or the dynamic data. If you do not specify an LB value, it uses all of the characters from the beginning of the data as a boundary. Boundary parameters are case–sensitive and do not support regular expressions. To further customize the search text, use one or more text flags. This attribute is required. See the Boundary Arguments section.
  • NOTFOUND: The handling option when a boundary is not found and an empty string is generated.
    "Notfound=error", the default value, causes an error to be raised when a boundary is not found.
    "Notfound=warning" ("Notfound=empty" in earlier versions), does not issue an error. If the boundary is not found, it sets the parameter count to 0, and continues executing the script. The "warning" option is ideal if you want to see if the string was found, but you do not want the script to fail.
    Note: If Continue on Error is enabled for the script, then even when NOTFOUND is set to "error", the script continues when the boundary is not found, but an error message is written to the Extended log file.
    This attribute is optional.
  • ORD: Indicates the ordinal position or instance of the match. The default instance is 1. If you specify "All," it saves the parameter values in an array. This attribute is optional.
    Note: The use of Instance instead of ORD is supported for backward compatibility, but deprecated.
  • RB: The right boundary of the parameter or the dynamic data. If you do not specify an RB value, it uses all of the characters until the end of the data as a boundary. Boundary parameters are case–sensitive and do not support regular expressions. To further customize the search text, use one or more text flags. This attribute is required. See the Boundary Arguments section.
  • RelFrameID: The hierarchy level of the HTML page relative to the requested URL. The possible values are ALL or a number. Click RelFrameID Attribute for a detailed description. This attribute is optional.
    Note: RelFrameID is not supported in GUI level scripts.
  • SaveLen: The length of a sub–string of the found value, from the specified offset, to save to the parameter. This attribute is optional. The default is –1, indicating to save to the end of the string.
  • SaveOffset: The offset of a sub–string of the found value, to save to the parameter. The offset value must be non–negative. The default is 0. This attribute is optional.
  • Search: The scope of the search—where to search for the delimited data. The possible values are Headers (Search only the headers), Body (search only body data, not headers), Noresource (search only the HTML body, excluding all headers and resources), or ALL (search body , headers, and resources). The default value is ALL. This attribute is optional.


Tuesday, May 8, 2012

General: Understanding Processor - Interrupt Processing

Interrupts are subjected to priority. The interrupt priority scheme is hardware-determined, but in the interest of portability it is abstracted by the Windows HAL. During interrupt processing, interrupts from lower-priority interrupts are masked so that they remain pending until the current interrupt processing completes. Following interrupt processing during which interrupts themselves are disabled, the operation system returns to its essor is once normal operating mode with the processor reset once more to receive interrupt signals. The proc again enabled for interrupts.

Strictly speaking, on an Intel processor, there is a class of interrupts used for switching between the user level and privileged OS code. Although this involves interrupt processing on the Intel microprocessor , we are not referring to that type of interrupts here. Switching privilege levels does not necessarily cause the executing thread to relinquish the processor. However, Windows does classify these OS supervisor call interrupts as context switches.

In Windows, hardware device interrupts are serviced by an interrupt service routine, or ISR, which is a standard device driver function. Device  drivers are extensions of the OS tailored to respond to the specific characteristics of the devices they understand and control. The ISR code executes at the interrupt level priority , with interrupts at the same or lower level disabled. An ISR is high priority by definition since it interrupts the regularly scheduled thread and executes until it voluntarily relinquishes the processor (or itself interrupted by a higher-priority interrupt).

The ISR normally signals the device to acknowledge the event, stops the interrupt from occurring, and saves the device status for later processing. It then schedules a deferred procedure call (DPC) to a designated routine that performs the bulk of the device-specified work associated with interrupt processing. DPCs are a special feature of Windows designed to allow the machine to operate enabled for interrupts as much as possible. DPC code executes at a higher priority than other OS privileged modes, but one that does not disable further interrupts from occurring and being serviced.

The DPC mechanism in Windows keeps the machine running in a state enabled for interrupts as much as possible. This architecture is especially useful with Intel PC Hardware where many devices connected to a single PCI  bus can share the same Interrupt Request Queue (IRQ) level. DPC routines execute from a separate DPC dispatcher queue, which Windows empties before it calls the Scheduler to re-dispatch an ordinary kernel or application thread. A typical function carried out by a DPC routine is to reset the device for the next operation and launch the next request if one is queued. When the DPC completes, a high-priority kernel or device driver thread then marks the I/O function complete. At the end of this chain events, a waiting thread transitions to the ready state, poised to continue processing now that the I/O it requested has completed.

When an interrupt occurs, the thread executing loses control of the processor immediately. When the DPC performing the bulk of the interrupt processing completes, the Windows Scheduler checks the Ready Queue again and dispatches the highest-priority thread. The interrupted thread does not necessarily regain control following interrupt processing because a higher-priority task may be ready to run. This is variously known as preemptive scheduling, preemptive multithreading or preemptive multitasking.

Wednesday, May 2, 2012

Automation Object Model

Automation Object Model

♦ Automation object model is nothing but collection of objects,methods and properties which are used to perform quicktest operations.Through out this object model we can perform any operation described in QTP interface. For every option in QTP menus(Interface) have Objects,methods and properties are there in this model.

♦ AOM is the concept to automate QTP itself.


Start  QTP, open an existing test and Run the Test:


Dim qtApp
Dim qtTest

'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application") 

'If QTP is notopen then open it
If  qtApp.launched <> True then 

qtApp.Launch 

End If 

'Make the QuickTest application visible
qtApp.Visible = True

'Set QuickTest run options
'Instruct QuickTest to perform next step when error occurs

qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False

'Open the test in read-only mode
qtApp.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", True 

'set run settings for the test
Set qtTest = qtApp.Test

'Instruct QuickTest to perform next step when error occurs
qtTest.Settings.Run.OnError = "NextStep" 

'Run the test
qtTest.Run

'Check the results of the test run
MsgBox qtTest.LastRunResults.Status

' Close the test
qtTest.Close 

'Close QTP
qtApp.quit

'Release Object
Set qtTest = Nothing
Set qtApp = Nothing 

Start  QTP, open an existing test and Run the Test  And Store Run Results in Specified Folder: 
Dim qtApp
Dim qtTest
Dim qtResultsOpt

'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application") 

'If QTP is notopen then open it
If  qtApp.launched <> True then 

qtApp.Launch 

End If 

'Make the QuickTest application visible
qtApp.Visible = True

'Set QuickTest run options
qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False

'Open the test in read-only mode
qtApp.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", True 

'set run settings for the test
Set qtTest = qtApp.Test

'Instruct QuickTest to perform next step when error occurs
qtTest.Settings.Run.OnError = "NextStep" 

'Create the Run Results Options object
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")

'Set the results location
qtResultsOpt.ResultsLocation = "D:\Result"

' Run the test
qtTest.Run qtResultsOpt 

'Check the results of the test run
MsgBox qtTest.LastRunResults.Status

'Close the test
qtTest.Close 

'Close QTP
qtApp.quit

'Release Object
Set qtResultsOpt = nothing
Set qtTest = Nothing
Set qtApp = Nothing

Start  QTP and open New test:


Dim qtApp
Dim qtTest

'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application") 

'If QTP is notopen then open it
If  qtApp.launched <> True then 
qtApp.Launch 
End If 

'Make the QuickTest application visible
qtApp.Visible = True

' Open a new test
qtApp.New 

Set qtApp = Nothing ' Release the Application object

 Open QTP and Connect to Quality Center and run QC script:


Dim qtApp ' Declare the Application object variable

'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application") 

'If QTP is notopen then open it
If  qtApp.launched <> True then 
qtApp.Launch 
End If 

'Make the QuickTest application visible
qtApp.Visible = True
If Not qtApp.TDConnection.IsConnected Then

' Make changes in a test on Quality Center with version control
qtApp.TDConnection.Connect "QC URL","DOMAIN Name","Project Name","User Name","Password",False

'QC URL = QC Server path
'DOMAIN Name = Domain name that contains QC project
'Project Name =Project Name in QC you want to connect to
'Username = Username to connect to Project
'Password = Password to connect to project
'False or True = Whether ‘password is entered in encrypted or normal. 
'Value is True for encrypted and FALSE for normal

'Example : qtApp.TDConnection.Connect
'"http://200.168.1.1:8080/qcbin","Default","proj1","qtpworld","qtp",false

End If

'Make Sure about your script path  and script name in QC
qtApp.Open "[QualityCenter] Subject\QCScriptPath\ScriptName", False
qtApp.Test.Run
qtApp.TDConnection.Disconnect

'Close QTP
qtApp.quit

'Release Object
Set qtApp = Nothing

Start  QTP, open an existing test, associate Object Repositories and save the test:

Dim qtApp
Dim qtTest
Dim qtRepositories

'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application") 
'If QTP is notopen then open it
If  qtApp.launched <> True then 
qtApp.Launch 
End If 

'Make the QuickTest application visible
qtApp.Visible = True
qtApp.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", False
 
' Get the object repositories collection object of the "SignIn" action
Set qtRepositories = qtApp.Test.Actions("SignIn").ObjectRepositories 

' Add  Object repositry "Reposit.tsr" if it's not already associated wit action "SignIn"

If qtRepositories.Find("D:\Reposit.tsr") = -1 Then 
    qtRepositories.Add "D:\Reposit.tsr", 1
End If

'Save the test
qtApp.Test.Save

'Close QTP
qtApp.quit

'Release Object
Set qtLibraries = Nothing
Set qtTest = Nothing
Set qtApp = Nothing

 Start  QTP, open an existing test, associate libraries and save the test:

Dim qtApp
Dim qtTest
Dim qtLibraries

'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application") 

'If QTP is notopen then open it
If  qtApp.launched <> True then 
qtApp.Launch 
End If 

'Make the QuickTest application visible
qtApp.Visible = True

qtApp.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", False

'Get the libraries collection object
Set qtLibraries = qtApp.Test.Settings.Resources.Libraries 

'If the library file "libraary.vbs" is not assiciates with the Test then associate it
If qtLibraries.Find("D:\libraary.vbs") = -1 Then 
    qtLibraries.Add "D:\libraary.vbs", 1  
End If

'Save the test
qtApp.Test.Save

'Close QTP
qtApp.quit

'Release Object
Set qtLibraries = Nothing
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object

Start QTP, Open an Existing Test and Define Environment Variables:

Dim qtApp

'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application") 

'If QTP is notopen then open it
If  qtApp.launched <> True then 
qtApp.Launch 

End If 

'Make the QuickTest application visible
qtApp.Visible = True
' Open the test

qtApp.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", False

' Set some environment variables
qtApp.Test.Environment.Value("Root") = "C:\"
qtApp.Test.Environment.Value("Password") = "QuickTest"
qtApp.Test.Environment.Value("Days") = 14

' Save the test
qtApp.Test.Save

'Close QTP
qtApp.quit

'Release Object
Set qtApp = Nothing

Start QTP with specified views:
Dim qtApp

'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application") 

'If QTP is notopen then open it
If  qtApp.launched <> True then 
qtApp.Launch 

End If 

'Make the QuickTest application visible
qtApp.Visible = True
' Open the test

qtApp.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", False

' Set some environment variables
qtApp.Test.Environment.Value("Root") = "C:\"
qtApp.Test.Environment.Value("Password") = "QuickTest"
qtApp.Test.Environment.Value("Days") = 14

' Save the test
qtApp.Test.Save

'Close QTP
qtApp.quit

'Release Object
Set qtApp = Nothing

Start QTP, Open an Existing Test and Get All Available Action Names From the Test:
Dim qtApp
'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application") 

'If QTP is notopen then open it
If  qtApp.launched <> True then 
qtApp.Launch 
End If 

'Make the QuickTest application visible
qtApp.Visible = True

qtApp.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", False, False

'Get count of Action in a test
oActCount=qtApp.Test.Actions.Count

For iCounter=1 to oActCount
' Get the first action in the test by index (start from 1)

MsgBox qtApp.Test.Actions(iCounter).Name

Next

'Close QuickTest
qtApp.Quit

' Release the Application object
Set qtApp = Nothing

Open and minimize QTP Window:
Dim qtApp
'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application") 

'If QTP is notopen then open it
If  qtApp.launched <> True then 
qtApp.Launch 
End If 

'Make the QuickTest application visible
qtApp.Visible = True
qtApp.WindowState = "Minimized" ' Maximize the QuickTest window
qtApp.WindowState = "Maximized" ' Maximize the QuickTest window

'Release Object
Set qtApp = Nothing