### QTP VBScript - Are you sure 1+1=2?

QTP VBScript contains different niceties. This article shows that 1 + 1 doesn't equal 2 sometimes.

 Exactly, 1 + 1 doesn't equal 2 sometimes.

Well, I've prepared this QTP script:
n1 = InputBox("Enter first number")
n2 = InputBox("Enter second number")
n1increased = n1 + 1

If n1increased = n2 Then
MsgBox n1 & " + 1 equals " & n2
Else
MsgBox n1 & " + 1 doesn't equal " & n2
End If

I will explain it step by step and show all entered data and generated result.
Read first number from user's input
I enter 1 as a first number:

Read second number from user's input
I enter 2 as a second number:

1. Increase first number by 1
n1increased = n1 + 1
2. Check whether first increased number equals to second number
If n1increased = n2 Then
MsgBox n1 & " + 1 equals " & n2
Else
MsgBox n1 & " + 1 doesn't equal " & n2
End If
And the result is:

Do you know why it is so? What is a reason?
The answer is simple. This is due to converting of VBScript types.

After you read first number (1) from user and assign it (value of course value, not user :) ) to variable, this variable has value of String type.
So, this is the same like n1 = "1"

When VBScript executes this line:
n1increased = n1 + 1
it sees, that we perform mathematical operation and converts n1 into number.
Then VBScript calculates n1 + 1 and the result (2) has a numeric type - Double (special double-precision floating-point value).

Here is the main point! 2 as Number is not the same as 2 as String. These values have different type and that's why they differ.
Simple visual example - two apples are not equal to two pears :)

I can demonstrate the above types converting.
I've added this code into our QTP script before if-then-else:
MsgBox "TypeName(n1): " & TypeName(n1)
MsgBox "TypeName(n1increased): " & TypeName(n1increased)
MsgBox "TypeName(n2): " & TypeName(n2)
And its result is:
That's why the value of number variable is not equal to the value of string variable.

Well, How to make that 1 + 1 = 2 ?
Answer: Convert string value to number with CInt function:
If n1increased = CInt(n2) Then
MsgBox n1 & " + 1 equals " & n2
Else
MsgBox n1 & " + 1 doesn't equal " & n2
End If
And the result is:
It works. It works correctly :)

I hope, you will keep in mind this issue with VBScript types converting. It can save your time during debugging of QTP scripts.

### Quality Center Multiple Choice Questions-5

41) By default, Quality Center sends e-mail in HTML format. To send e-mail as
plain text instead, edit the ……. parameter in the Site Configuration tab in Site
A) EMAIL_FORMAT
B) EMAIL_FORM
C) MAIL_FORMAT
D) QC_MAIL_FORMAT

42) You can copy a requirement within the same project or between projects.
Which of the below items are copied at the time of copying a requirement.
A) Test coverage.
C) risk-based quality management data
D) All of above
E) None of above

43) You can also move a requirement to a new location in the requirements tree by
dragging it..
A) True
B) False

44) You can delete a requirement from the Requirements module. Deleting a
requirement does not delete its child requirements, tests coverage, requirement

A)True
B) False

45) There are two methods you can use to create tests from requirements:
A) Convert Requirements to Tests & Generate a Test from Requirements
B) Convert Requirements to Tests & Convert a Test from Requirements
C) Convert Requirements to Tests & Generate a Requirement from Tests
D) Convert a Test from Requirements & Generate Requirements to Tests

46) When analyzing the impact of a change proposed in a specific requirement,
the traceability links indicate the other ...... that the change might affect.
A) tests
B) requirements
C) tests & requirements
D) None

indicate requirements that are affected by a selected requirement.
A) Trace from, Trace to
B) Trace to, Trace from
C) From trace, To trace
D) None of above

48) When a requirement changes, Quality Center alerts the affected requirements.
The alerts can be seen by.......
A) Author of the requirement
B) users authorized by the Author of the requirement
C) all users

49) while Defining Traceability Relationships, You cannot add a requirement
traceability link by dragging a requirement from the requirements tree to the
appropriate grid..
A) True
B) False

50) While viewing Traceability Impact, the Impact Analysis tab helps you
understand the many associations and dependencies that exist between the ........
by displaying them in a hierarchical tree structure.
A) Tests
B) Requirements
C) Both
D) None

### Quality Center Multiple Choice Questions-4

31) QA Manager changes a requirement from a ……….. status to a Reviewed
status once it is approved.
A) Released
B) Tested
C) Not reviewed
D) None of these

32) You can also import requirements to your Quality Center project from Microsoft
Word, Excel, or other third-party requirement management tools. To import
requirements, you must first install the appropriate………
C) HP Quality Center

33) The Requirements Grid view enables you to display requirements in a
…………….view.
A) Flat
B) Hierarchical
C) Flat-hierarchical
D) Flat non-hierarchical

34) The …………view enables you to analyze the breakdown of child requirements
according to test coverage status..

A) Coverage Analysis
B) Coverage Requirements
C) Coverage
D) Coverage Tests

35) You can access the Requirements menu bar from the Requirements module
by pressing the shortcut key …….
A) F1
B) F9
C) Ctrl + R
D) Alt + R

36) You can use the ………to restrict and dynamically change the fields and
values in the Requirements module.
A) Script Edit
B) Scriptor Editor
C) Script Editor
D) Script Editing

37) The Requirements module enables you to define and manage your……...
A) requirements
B) All requirements
C) some requirements
D) Tedious requirements

38) You can rename or delete Requirements root folder.
A) true
B) False

39) You can search for a particular requirement in the requirements tree or in the
requirements grid using the …….command.
A) Search
B) Find
C) Search All
D) Find All

40) You can replace field values in the requirements tree or in the requirements
grid using the …….command.
A) Replace
B) Replace All
C) Find & Replace
D) Replace & Find

### Quality Center Multiple Choice Questions-3

21) You can view a list of alerts for a ………… entity.
A) A test in the test plan tree or Test Grid
B) A test instance in the Execution Grid
C) None of above
D) Both A) & B)

22) A red flag indicates that the alert is.........
A) New
B) Old
D) Urgent

23) A gray flag indicates that the alert ………..
A) New
D) Urgent

A) True
B) False

25) Quality Center assigns the image a unique file name with a ..... extension.
A) .jpeg
B) .gif
C) .doc
D) .jpg

26) A ………..is a view of a Quality Center window with the settings you apply to it.
A) Personal View
B) My view
C) Favorite View
D) My QC View

27) You save favorite views in ........
A) Favorite folder
B) Personal folder
C) Both A) & B)
D) Public & Private folder

28) You can define the number of views displayed on the menu by setting the
…………….. parameter in the Site Configuration tab in Site Administration.
A) favorites
B) favorites_Depth
C) favorites_view
D) favorites_Path

29) The requirements specification workflow consists of the following:
A) Define Testing Scope, Create Requirements, Detail Requirements, Assign to
Releases, Analyze Requirements
B) Define Testing Scope, Detail Requirements, Create Requirements, Assign to
Releases, Analyze Requirements
C) Define Testing Scope, Create Requirements, Detail Requirements, Analyze
Requirements, Assign to Releases
D) Define Testing Scope, Create Requirements, Analyze Requirements, Detail
Requirements, Assign to Releases

30) Requirement topics are recorded in the Requirements module by creating a
A) Requirements cycle
B) Requirements tree
C) Requirements plan
D) Requirements module

### QTP Questions Set 2

11) The Information pane provides a list of............. in the test:
A) Semantic errors
B) Syntax errors
C) Common errors
D) Logic errors

12) When we switch from Expert view to the Keyword view, QTP automatically
checks for syntax errors in the test and shows them in the information pane.
A) True
B) False

13) If the information pane is not open, QTP automatically opens it in case a
syntax error is detected.
A) True
B) False

14) ..................... provides a list of the resources that are specified in your test but
cannot be found.
A) Missing pane
B) Missing Resources pane
C) Resources pane
D) Missing Items pane

15) Whenever you open a test or a function library, QTP automatically checks for

the availiblity of specified resources.
A) True
B) False

16) The Data Table does not assists you in parameterizing your test.
A) True
B) False

17) Tabs in the Debug Viewer pane are:
A) Watch, Variables, Debug
B) Watch, Data, Command
C) Watch, Variables, Command
D) View, Variables, Command

18) ............... tab enables you to view the current value of any variable or VBScript
expression.
A) Watch
B) VIew
C) Locate
D) Current

19) The .... tab displays the current value of all variables that have been
recognized up to the last step performed in the run session.
A) View
B)Variables
C) Locate
D) Current

20) The .........tab enables you to run a line of script to set or modify the current
value of a variable or VBScript object in your test or function library.
A) View
B) Variables
C) Command
D) Current

### Quality Center Multiple Choice Questions-1

1) Test management with Quality Center involves …. Phases.
A) Four
B) Five
C) Six
D) Seven

2) The phases of Test management with Quality Center in order are:
A) Specify Releases, Specify Requirements, Plan Tests, Execute Tests, Track
Defects
B) Specify Requirements, Specify Releases, Plan Tests, Execute Tests, Track
Defects
C) Specify Requirements, Plan Tests, Specify Releases, Execute Tests, Track
Defects
D) Specify Releases, Specify Requirements, Plan Tests, Track Defects, Execute
Tests

3) By creating a list of authorized users and assigning each user a password and
user group, you control the kinds of additions and modifications each user makes
to the project.
A) True
B) False

4) The …….determines the privileges that the user has within a project.
A) User ID
B) User Name
C) User group
D) User SID

5) You can import data from Word or Excel to a Quality Center project.
A) True
B) False

6) Quality Center 9.2 prompts you to install Microsoft .NET ...... if it is not already
A) Framework 2.0
B) Framework 1.0
C) Framework 3.0
D) Framework 4.0

7) When you connect to a project, the Quality Center main window opens and
displays the module in which you were last working.
A) True
B) False

8) The ….can change and override a user’s properties or password.

9) You can filter Quality Center data to display only those records that meet the
criteria that you define. How many filters can you define
A) Single item as a filter
B) Two items as a filter
C) Multiple items as filter
D) Five items as filter

10) In the test plan tree, you can define the ……filter for associated test sets as
“Open”. This ensures that only tests that belong to an open test set are displayed.
A) Double
B) Twice
C) Cross
D) Multiple