Академический Документы
Профессиональный Документы
Культура Документы
cid=38
Descriptive Programming
Arguments:
Regular Expression
condition: Numeric or string expression that is True or False. If condition is Null, condition is treated as False.
Error Handling & Recovery
Scenario
statements: One or more statements that are repeated while or until condition is True.
Output Values
Counter = 1
Synchronization
Do While Counter < 4
Environment Variables
Total =Inputbox("Please enter the total marks in numbers")
XML
If Total < 50 Then
Outlook
MsgBox "Fail"
Reporting Defect
ElseIf Total >=50 and Total <=60 then
Else
End If
Counter = Counter + 1
Loop
Example:
Counter = 1
Do
MsgBox "Fail"
1 of 5 1/29/2016 3:38 AM
QTPWorld http://www.qtpworld.com/index.php?cid=38
Msgbox "Distinction"
Else
End If
Counter = Counter + 1
Example:
Counter=counter + 1
If counter = 6 Then
Exit Do
End If
Print Counter
Loop
Example:
Do
Counter=Counter + 1
If Counter = 6 Then
Exit Do
End If
Print Counter
For...Next Statement
Syntax:
Arguments:
counter: Numeric variable used as a loop counter. The variable can't be an array element or an element of a user-defined type.
step: Amount counter is changed each time through the loop. If not specified, step defaults to one.
statements: One or more statements between For and Next that are executed the specified number of times.
Example:
For...Next
Counter = 1
For Counter = 1 to 4
MsgBox "Fail"
2 of 5 1/29/2016 3:38 AM
QTPWorld http://www.qtpworld.com/index.php?cid=38
Msgbox "Distinction"
Else
End If
Next
Example:
Counter = 1
Result = 0
For Counter = 1 to 10 step 3
Result=Result + Counter
Print Result
Next
Example:
'Decrement loop by 2
Print Counter
Next
Example:
For Counter=1 to 10
If Counter=6 Then
Exit for
End If
Print Counter
Next
For Each...Next: Repeats a group of statements for each element in an array or collection.
Syntax:
Arguments:
Variable used to iterate through the elements of the collection or array. For collections, element can only be a Variant
element: Variable, a generic Object variable, or any specific Automation object variable. For arrays, element can only be a Variant
variable.
statements: One or more statements that are executed on each item in group.
If...Then...Else Statement
Syntax:
OR
If condition Then
[statements]
[ElseIf condition-n Then
[elseifstatements]] . . .
[Else
[elsestatements]]
End If
Arguments:
3 of 5 1/29/2016 3:38 AM
QTPWorld http://www.qtpworld.com/index.php?cid=38
Example:
'If...Then...Else
MsgBox "Pass"
Else
Msgbox "Fail"
End If
Example:
'If....ElseIf
MsgBox "Fail"
Msgbox "Distinction"
Else
End If
Select Case: Executes one of several groups of statements, depending on the value of an expression.
Syntax:
Arguments:
statements-n: One or more statements executed if testexpression matches any part of expressionlist-n.
elsestatements-n: One or more statements executed if testexpression doesn't match any of the Case clauses.
Example:
'Select Case
Case "RED"
Case "BLUE"
Case "GREEN"
4 of 5 1/29/2016 3:38 AM
QTPWorld http://www.qtpworld.com/index.php?cid=38
Case ELSE
While...Wend statement
Syntax:
While condition
Version [statements]
Wend
Arguments:
condition: Numeric or string expression that evaluates to True or False. If condition is Null, condition is treated as False.
Example:
'While...Wend
Counter =1
While Counter < 4
Total =Inputbox("Please enter the total marks in numbers")
If Total < 50 Then
MsgBox "Fail"
Msgbox "Distinction"
Else
End If
Counter=counter + 1
Wend
With statement
Syntax:
With object
statements
End With
Arguments:
Copyright QTPWorld.com 2013 Home | Demo videos | Students | Training | FAQ's | Feedback | About Us Designed By WebZone
5 of 5 1/29/2016 3:38 AM