Active TopicsActive Topics  Display List of Forum MembersMemberlist  CalendarCalendar  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin


 One Stop Testing ForumTesting Tools @ OneStopTestingWinRunner @ OneStopTesting

Message Icon Topic: Winrunner Conditional Statements

Post Reply Post New Topic
Author Message
Mithi25
Senior Member
Senior Member
Avatar

Joined: 23Jun2009
Online Status: Offline
Posts: 288
Quote Mithi25 Replybullet Topic: Winrunner Conditional Statements
    Posted: 26Oct2009 at 1:05am
if/ Else Statement

An if/ else statement executes a statement if a condition is true; otherwise, it
executes another statement. It has the following syntax:

if ( expression )
statement1;
[ else
statement2; ]

For example, the if/ else statement below checks that the Flights button in the Flight Reservation window is enabled. It then sends the appropriate message to the report.


button_get_state (" FLIGHT", value);
if (value != ON)
    report_msg(" The Flights button was successfully enabled");
else
    report_msg(" Flights button was not enabled. Check that values for Fly From            
    and Fly To are valid");

Switch Statement:

A switch statement enables WinRunner to make a decision based on an
expression that can have more than two values. It has the following syntax:

switch (expression )
{
case case_ 1:
statements
case case_ 2:
statements
default: statement( s)
}
 switch (num)
{
    case 1: #First
    obj_check_gui(" Price:", "list1. ckl", "gui1", 1);
    break;
    case 2: #Business
    obj_check_gui(" Price:", "list2. ckl", "gui2", 1);
    break;
}
For Loop
A for loop instructs WinRunner to execute one or more statements a specified
number of times.

It has the following syntax:

for ( [ expression1 ]; [ expression2 ]; [ expression3 ] )
statement
For example, the for loop below selects the file UI_TEST from the File Name list in the Open window. It selects this file five times and then stops.

set_ window (" Open")
for (i= 0; i< 5; i++)
list_ select_ item (" File Name:_ 1", "UI_ TEST"); # Item Number 2

While Loop
 A while loop executes a block of statements for as long as a specified condition
is true.

It has the following syntax:

while ( expression )
statement ;
For example, the while statement below performs the same function as the for loop.

set_ window (" Open");
i= 0;
while (i< 5)
{
    i++;
    list_select_item (" File Name:_1", "UI_TEST"); # Item Number 2
}
 Do/While Loop:

A do/while loop executes a block of statements for as long as a specified condition
is true. A do/while loop has the following syntax:

do
statement
while (expression);
 For example, the do/while statement below opens and closes the Order dialog
box of Flight Reservation five times.

set_window (" Flight Reservation");
i= 0;
do
{
menu_select_item (" File; Open Order...");
set_window (" Open Order");
button_press (" Cancel");
i++;
}
while (i< 5);

Assignment 6             Using TSL  Functions:

  •  Start recording in Context Sensitive mode
  •  Open order #4
  •  Open the Fax Order dialog box
  •  Query the # Tickets field, Ticket Price field & Total field
  •  Click Cancel to close the Fax dialog box
  •  Stop recording and save the test
  •  Save the test as test6
  •  Create a function to check the total and report it to the result window
  •  Run the test
  •  Review the results



Post Resume: Click here to Upload your Resume & Apply for Jobs

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.109 seconds.
Vyom is an ISO 9001:2000 Certified Organization

© Vyom Technosoft Pvt. Ltd. All Rights Reserved.

Privacy Policy | Terms and Conditions
Job Interview Questions | Placement Papers | Free SMS | Freshers Jobs | MBA Forum | Learn SAP | Web Hosting