Micro Focus QTP (UFT) Forums
Conditional Statement (If.......else) - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Conditional Statement (If.......else) (/Thread-Conditional-Statement-If-else)



Conditional Statement (If.......else) - Unleash Rajesh - 08-27-2011

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....


RE: Conditional Statement (If.......else) - Unleash Rajesh - 09-06-2011

Get me a solution..........




RE: Conditional Statement (If.......else) - tarun - 09-06-2011

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




RE: Conditional Statement (If.......else) - Unleash Rajesh - 09-07-2011

Ya the same concept


RE: Conditional Statement (If.......else) - tarun - 09-07-2011

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.