Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Wednesday 22 May 2019

Working with WebList in UFT

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=0to 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=0to 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=1to 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=0to 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=1to 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=1to 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"
            EndIf
    Next

EndFunction


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."
EndIf
'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."
EndIf

No comments:

Post a Comment

Note: only a member of this blog may post a comment.