Menu
There are various ways of handling errors in QTP. There are three possible types of errors, one would encounter, while working with QTP. They are −
If you add new parts, already numbered objects are not renumbered to suit the sorting order by, for example, the x coordinate. In this case you should renumber the parts. Applying numbering. When you apply numbering, Tekla Structures assigns marks to parts and assemblies.
- Syntax Errors
- Logical Errors
- Run Time Errors
Error Types
Syntax Errors
Syntax errors are the typos or a piece of the code that does not confirm with the VBscripting language grammar. Syntax errors occur at the time of compilation of code and cannot be executed until the errors are fixed.
To verify the syntax, use the keyboard shortcut Ctrl+F7 and the result is displayed as shown below. If the window is not displayed one can navigate to 'View' → 'Errors'.
Logical Errors
If the script is syntactically correct but it produces unexpected results, then it is known as a Logical error. Logical error usually does not interrupt the execution but produces incorrect results. Logical errors could occur due to variety of reasons, viz- wrong assumptions or misunderstandings of the requirement and sometimes incorrect program logics (using do-while instead of do-Until) or Infinite Loops.
One of the ways to detect a logical error is to perform peer reviews and also verify the QTP output file/result file to ensure that the tool has performed the way it was supposed to do.
RunTime Errors
As the name states, this kind of error happens during Run Time. The reason for such kind of errors is that the script trying to perform something is unable to do so and the script usually stops, as it is unable to continue with the execution. Classic examples for Run Time Errors are −
- File NOT found but the script trying to read the file
- Object NOT found but the script is trying to act on that particular object
- Dividing a number by Zero
- Array Index out of bounds while accessing array elements
Handling Run-Time Errors
There are various ways to handle errors in the code.
1. Using Test Settings − Error handling can be defined the Test Settings by Navigating to 'File' >> 'Settings' >> 'Run' Tab as shown below. We can select any of the specified settings and click 'OK'.
2. Using On Error Statement − The ‘On Error’ statement is used to notify the VBScript engine of intentions to handle the run-time errors by a tester, rather than allowing the VBScript engine to display error messages that are not user-friendly.
- On Error Resume Next − On Error Resume Next informs the VBScript engine to process executing the next line of code when an error is encountered.
- On error Goto 0 − This helps the testers to turn off the error handling.
3. Using Err Object − Error object is an in-built object within VBScript that captures the run-time error number and error description with which we are able to debug the code easily.
- Err.Number − The Number property returns or sets a numeric value specifying an error. If Err.Number value is 0 then No error has occurred.
- Err.Description − The Description property returns or sets a brief description about an error.
- Err.Clear − The Clear method resets the Err object and clears all the previous values associated with it.
Example
4. Using Exit Statement − Exit Statements can be used along with Err object to exit from a test or action or iteration based on the Err.Number value. Let us see each one of those Exit statements in detail.
- ExitTest − Exits from the entire QTP test, no matter what the run-time iteration settings are.
- ExitAction − Exits the current action.
- ExitActionIteration − Exits the current iteration of the action.
- ExitTestIteration − Exits the current iteration of the QTP test and proceeds to the next iteration.
5. Recovery Scenarios − Upon encountering an error, recovery scenarios are triggered based on certain conditions and it is dealt in detail in a separate chapter.
6. Reporter Object − Reporter Object helps us to report an event to the run results. It helps us to identify if the concerned action/step is pass/fail.
To make a new dimension or any object in an SQL Server 2008 Analysis Services database, the user must be in a role that has “Full control ( Administrator)” permissions. I confirmed this by breaking my role, getting an error, and researching the source code which throws the error to see what conditions it checks.
The product checks for the current user’s sessions to be an Administrator within the database when creating new objects by saving/deploying them from BIDS to the Analysis Services.
IF the user does not have Full control, then when deploying or saving the new object, the following error may appear
TITLE: Microsoft Visual Studio
Either the 'machinenameusername' user does not have permission to create a new object in 'databasename', or the object does not exist.
Test Methodology:
1. Make a new role under a database of your choosing in Analysis Services in SSMS object explorer.
a. On the general tab, name the role, and check the two boxes “process database” and “read definition”
b. On the membership tab, add a local windows account on my machine machinenameaccountname
2. Using the command prompt, launch BIDS as the new local account that is a member of that new role to test my ability to create new dimensions.
Runas /user:machinenameaccountname 'C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDEdevenv.exe'
Connect to the Server and to the database in BIDS
Note I can see the definitions of dimensions since I have read definition permission.
3. In BIDS Solution Explorer, expand Dimensions. Right click to run the wizard to create a new dimension
Step through the configuration of the dimension.
Error
TITLE: Microsoft Visual Studio
------------------------------
Either the 'machinenameusername' user does not have permission to create a new object in 'databasename', or the object does not exist.
------------------------------
BUTTONS:
OK
------------------------------
The dimension is still visible in BIDS, but cannot be saved/deployed to the server.
4. Added permissions so the new dimension can be saved.
a. Tried - On the role from #1 above, click on the cube tab. On the cube, set the access to Read/Write. That was not sufficient to save a new dimension.
b. Tried – On the role from #1 above, edit the general tab, and check the 3rd box - “Full control” checkbox. Now the save worked. Now all other tabs in the security are grayed out.
Note: The equivalent XMLA that is run under the covers for creating a dimension is an ALTER with AllowCreate=True to make the new objects.
<Batch xmlns='http://schemas.microsoft.com/analysisservices/2003/engine'>
<Alter AllowCreate='true' ObjectExpansion='ExpandFull'>
<Object>
<DatabaseID>dbname</DatabaseID>
<DimensionID>dimName</DimensionID>
</Object>
<ObjectDefinition>
…
</ObjectDefinition>
</Alter>
</Batch>