Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FOR loop with nested CASE
#1
Not Solved
Hi All,

I have a unique situation where I must click on an image on the page to reveal the list of items then I have to set the webelement to the desired item in the list. I want to create multiple rows with a FOR statement and it works when I use the same item name each time:

Code:
for i =1 to 3
    datatable.setcurrentrow(i)
    returnvalue=datatable.value("invoiceNumber","Add_Multiple_Invoices")
Browser("Suppliers and Invoices").Page("Suppliers and Invoices").Image("spacer").Click
'Browser("Suppliers and Invoices").Page("Suppliers and Invoices").WebElement("Cleaning Supplies").Click


I want to incorporate a CASE statement or some code that will allow me to put a different value maybe from a table instead of it always being "Cleaning Supplies" . So something like this maybe :

Code:
for i =1 to 3
    datatable.setcurrentrow(i)
    returnvalue=datatable.value("invoiceNumber","Add_Multiple_Invoices")
Browser("Suppliers and Invoices").Page("Suppliers and Invoices").Image("spacer").Click
Select Case Category
        Case i = 1
returnCategory=datatable.value("Category","Add_Multiple_Invoices")

Any ideas on what I am doing wrong? The For Loop works, the Case does not.

Thanks,
Charles
Reply
#2
Not Solved
Hi Charles
below is Select case Syntax

Code:
MyVar="Red"
Select Case MyVar
      Case "red"     document.bgColor = "red"
      Case "green"   document.bgColor = "green"
      Case "blue"    document.bgColor = "blue"
      Case Else      MsgBox "pick another color"
End Select
Reply
#3
Not Solved
Hi charles,

If you are using web application and want to click or select each webList item then you can probably use index property for selecting each and every list item with the help of For loop, may be you will solve your problem.

Thanks
Mahesh
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Infinit loop Suma Parimal 1 2,778 05-29-2014, 01:22 PM
Last Post: basanth27
  Exit Do loop shipu 1 4,902 12-20-2013, 06:33 AM
Last Post: basanth27
Smile Infinite FOR loop issue Sivapratha 3 4,446 04-01-2013, 09:44 AM
Last Post: basanth27
  Not Invoked particular Test Case kotaramamohana 6 4,205 12-30-2011, 05:39 PM
Last Post: ravi.gajul
  Do Until loop returning failure mitch 0 3,599 05-27-2011, 12:20 AM
Last Post: mitch

Forum Jump:


Users browsing this thread: 2 Guest(s)