Micro Focus QTP (UFT) Forums

Full Version: Conditional Statement (If.......else)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi.......

In my application, the values changes dynamically in fields.....so i tried to use the concept of conditional statements........

Say for eg: Have a field named as customer,...By default, the drop down list contains "select...and Add new"..when ever user adds the customer in add new, the value changes dynamically..How can i overcome this using descriptive programming of QTP.

The following conditions be applied for this scenario......
1.Once the customer name is added in add new, second time i want to select the add new and add another customer(in different name) at run time.. This has to repeated for six customers..
2.If add new field shows "This customer name already exists" then i have to add some other customer in variant name...
3. If six customers gets added in add new, i want to select customers randomly from the drop down without trying for add new.....

Help me out....
Get me a solution..........

is the position of 'Add New' remains the same in the list or does it keeps changing also

e.g.
1. I am assuming that the fist time the list looks like
Select a Value
Add New
2. When I have added 'Tarun' using add new, the second time the list should be
Select a Value
Tarun
Add New
3. If I add a new value as Rajesh then the list should be
Select a Value
Rajesh
Tarun
Add New

please confirm

Ya the same concept
Use the following code to add six new customers

Code:
If DataTable.Value("Customer",dtGlobal) = "New"
   Browser.Page.WebList.Select "Add New"
   Code to add a new customer goes here
Else
   Browser.Page.WebList.Select DataTable.Value("Customer",dtGlobal)
   Code after selecting the customer goes here
End IF

Assumptions:

1. You have a column, named "Customer", in the global sheet
2. The first six enteries in this column are "New" (to create a new customer)
3. The enteriers after 6 are the customer names, in random order, which we have added in first 6 iterations.