Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
adding two conditions into a while statement
#1
Solved: 11 Years, 3 Months, 3 Weeks ago Question 
Hi guys,
I have a situation which is giving me a lot of troubles.
I have two conditions to be done, for e.g:
I have a table of e.g. 15 rows and two columns: oRow = 15
also each row have it's text: strText = "textFromRow"
to get the text I am using GetCellData:
Code:
Browser("URL:=" &Environment.Value("baseUrl")).Page("URL:=" &Environment.Value("baseUrl")).WebTable("micclass := WebElement", "class := ledgerAvlb_box_right", "Html Tag := TD", "Text := Sales Ledger (SLC + SLCX).*", "Index:=8").GetCellData("6","1")
-- on the second column I have the values of the names from 1st columns.

the idea is that I need a while statement I think (not sure), where to add the condition:

Code:
'counting the rows
oRow = Browser("URL:=" &Environment.Value("baseUrl")).Page("URL:=" &Environment.Value("baseUrl")).WebTable("micclass := WebElement", "class := ledgerAvlb_box_right", "Html Tag := TD", "Text := Sales Ledger (SLC + SLCX).*", "Index:=8").RowCount

' increasing the value of i to oRow
For i = 0 to i = oRow - 1
' get the data from cell(i) to find if it is the same as we need
    strText = Browser("URL:=" &Environment.Value("baseUrl")).Page("URL:=" &Environment.Value("baseUrl")).WebTable("micclass := WebElement", "class := ledgerAvlb_box_right", "Html Tag := TD", "Text := Sales Ledger (SLC + SLCX).*", "Index:=8").GetCellData(i,"1")
' comparing the data from cell(i)
                ' 1st condition - if it's pass we shouldn't continue the second one
        If strText <> "Less Client account (FIU)" then
                        ' the second condition
            While i <> oRow - 1 Do i = i + 1 Until
                Loop Until strText <> "Less Client account (FIU)"
                    Loop While i <> oRow - 1
                    strText = Browser("URL:=" &Environment.Value("baseUrl")).Page("URL:=" &Environment.Value("baseUrl")).WebTable("micclass := WebElement", "class := ledgerAvlb_box_right", "Html Tag := TD", "Text := Sales Ledger (SLC + SLCX).*", "Index:=8").GetCellData(i,"1")
        Else
                        ' get the value of the second cell from the "Less Client account (FIU)" column
            New_LessClientAccountFIU_Value = Browser("URL:=" &Environment.Value("baseUrl")).Page("URL:=" &Environment.Value("baseUrl")).WebTable("micclass := WebElement", "class := ledgerAvlb_box_right", "Html Tag := TD", "Text := Sales Ledger (SLC + SLCX).*", "Index:=8").GetCellData(i,"2")
            Reporter.ReportEvent micPass, "PASS", "The item '" & strText & "' exists on the screen, and it's value is: '" & New_LessClientAccountFIU_Value & "'!"
        End IF

the conditions are:
the idea is that when 1st condition gets passed (If strText = "Less Client account (FIU)"), than we should get a report message(PASS), if not than it should do i+1 while i=oRow-1 (max nr of rows within the table) and give us an error report message.

what I am doing here inside the code(I am trying to do) is:
count all rows, then to increase row's nr i=1 while the necessary text will be equal with the text from that row and also to do this while maximum times = count nr.

please can anyone help me with that?
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi
Here i am understanding your question,
1. There is table with 15 X 2 (15 Rows X 2 Columns)
2. Select the cell value from 1st column 1st row.
3. Compare the data fetched in the step 2 with "Less Client account (FIU)"
4. If it is not equal then go on to next row till 15th row.
5. At the end of 15th row, if the text not found, log error report message.

Am i correct? Is this waht exactly you need? pls Let me know, i will try to answer.
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Kavita, yep you're right.
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Then try this, I am taking the rCount and cCount as 2 and 15 as table is of fixed size else take the counts.
Code:
StrToCompare="Less Client account (FIU)"
For i=1 To 2
  j=1
  Flag=0
  Do While (Flag=0 AND j<16)    
    Str=Browser("BrowserProp").Page("PgProp").WebTable("TblProp").GetCellData(i,j)
    If (StrComp(StrToCompare,Str)=0) Then
      Flag=1
      Exit Do
    End If
      j=j+1
  Loop
  If (Flag=1) Then
    Reporter.ReportEvent micPass, "PASS", "The item","Item Found in the column" & i
  else
    Reporter.ReportEvent micPass, "PASS", "The item","Item Not Found in the column"&i
  End If
Next
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
(10-08-2010, 10:27 AM)KavitaPriyaCR Wrote: Then try this, I am taking the rCount and cCount as 2 and 15 as table is of fixed size else take the counts.
Code:
StrToCompare="Less Client account (FIU)"
For i=1 To 2
 j=1
 Flag=0
 Do While (Flag=0 AND j<16)    
   Str=Browser("BrowserProp").Page("PgProp").WebTable("TblProp").GetCellData(i,j)
   If (StrComp(StrToCompare,Str)=0) Then
     Flag=1
     Exit Do
   End If
     j=j+1
 Loop
 If (Flag=1) Then
   Reporter.ReportEvent micPass, "PASS", "The item","Item Found in the column" & i
 else
   Reporter.ReportEvent micPass, "PASS", "The item","Item Not Found in the column"&i
 End If
Next

Thank you KavitaPriyaCR, I'll try it and will let you know.
Reply
Jump to the post that solved this thread.


Possibly Related Threads…
Thread Author Replies Views Last Post
  Uft: Adding a property to all ojects into Repository ProTester 0 1,361 06-09-2017, 12:48 AM
Last Post: ProTester
  adding an object to OR seven 1 2,658 02-17-2014, 02:23 PM
Last Post: basanth27
  How to access webtables without adding into Object Repository ramkumarad 7 9,678 12-30-2013, 07:38 PM
Last Post: Sathiya
  vb script to stop execution of functions if conditions fail visitjaga 1 7,391 12-05-2013, 12:26 AM
Last Post: ravi.gajul
  Adding Visual Relation id via script to new object jcraig26 1 4,105 06-24-2013, 01:26 PM
Last Post: ourhari

Forum Jump:


Users browsing this thread: 3 Guest(s)