Friday, July 5, 2013

Working with WebList

'============= Ways to select value from WebList =======================

Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").WebList("name:=lr").Select "#3"
Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").WebList("name:=lr").Select (1)
Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").WebList("name:=lr").Select "English"


'========== To Count Number of WebList in a Page Using Mic Class =================

Set oWebList=Description.Create
oWebList("micclass").value="WebList"
set objList=Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").ChildObjects(oWebList)
vrCount = objList.Count

For i=0 to vrCount-1
msgbox objlist(i).getroproperty("name")
Next

'=========== To Count Number of WebList in a Page Using HTMLTag ==============

Set oWebList=Description.Create
oWebList("html tag").Value = "SELECT"
Set objList=Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").ChildObjects(oWebList)
vrCount = objList.Count

For i=0 to vrCount-1
msgbox objlist(i).getroproperty("name")
Next

'================================ To Get Values of  all items present in any particular WebList  ============================================

    vrItemCount = Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").WebList("name:=as_filetype").GetROProperty("items count")

For j=1 to vrItemCount
vrValue = Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").WebList("name:=as_filetype").GetItem(j)
msgbox vrValue
Next

'============== To Get All the Values of  all WebList  in a WebPAge===================

Set oWebList=Description.Create
oWebList("micclass").value="WebList"
set objList=Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").ChildObjects(oWebList)
vrCount = objList.Count

For i=0 to vrCount-1
vrWebListName = objlist(i).getroproperty("name")
vrItemCount = Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").WebList("name:="&vrWebListName).GetROProperty("items count")
msgbox vrItemCount
For j=1 to vrItemCount
vrValue = Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").WebList("name:="&vrWebListName).GetItem(j)
msgbox vrValue
Next
Next

'===========  To Check Existence of Item in Web List ======================

Function fnWebLIstItemExistence(vrSearchItem)

vrItemCount = Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").WebList("name:=as_filetype").GetROProperty("items count")
msgbox vrItemCount


For j=1 to vrItemCount
vrWebItem = Browser("name:=Google Advanced Search").Page("title:=Google Advanced Search").WebList("name:=as_filetype").GetItem(j)
If vrSearchItem = vrWebItem Then
Reporter.ReportEvent micPass, "Result", "vrSearchItem Exist in the Web List"
Else
Reporter.ReportEvent micFail, "Result", "vrSearchItem not Found in the Web List"
End If
Next

End Function


Call fnWebLIstItemExistence("Shockwave Flash (.swf)")


' ======= To Select more than one Item in a WebList ==============================

'The following example uses the ExtendSelect method to select two additional items from a WebList object and then checks
'if the items were actually selected. The results of the
'check are sent to the Test Results.

Browser("Find a Flight: Mercury").Page("Fill-Out Form Example").WebList("what-to-wear").Select "Rugby Shirt"
Browser("Find a Flight: Mercury").Page("Fill-Out Form Example").WebList("what-to-wear").ExtendSelect "Leather Jacket"
Browser("Find a Flight: Mercury").Page("Fill-Out Form Example").WebList("what-to-wear").ExtendSelect "Boots"

'Check if all items that were selected in the previous steps are
'actually selected in the list and send

CurrentSelection = Browser("Find a Flight: Mercury").Page("Fill-Out Form Example").WebList("what-to-wear").GetROProperty("selection")
If CurrentSelection <> "Rugby Shirt;Leather Jacket;Boots" Then
    Reporter.ReportEvent micFail, "ExtendSelect", "The list does not contain all of the selected items."
Else
   Reporter.ReportEvent micPass, "ExtendSelect", "The list contains all selected items."
End If

'============= To check if Items in a WebList are sorted or not=================



2 comments: