Micro Focus QTP (UFT) Forums
VB Scripting - 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: VB Scripting (/Thread-VB-Scripting--9158)



VB Scripting - spixol - 12-15-2019

Hi Everyone,

I hope someone can help. I am new to software automation testing and have been assigned a task to automate the testing to this app that is used to provision access to, so as you can imagine there are a lot of "checkboxes". What we have first worked out a descriptive code that goes through the app and works out if any of the "checkboxes" are "checked" and first "unchecks" them, then it goes and "checks" them one by one and reports back any errors if there is any issues.

I am wanting a function that goes into the page after a refresh and that passes a message that indicates a "pass" if they're all "checked" or a "fail" if one of them is "unchecked.

Here is the code so far that does what was mention on the first paragraph:
Code:
unction UDF_ProvisionApp(param_array)
    
Set test = description.Create    
test("micclass").value = "WebElement"
test("acc_name").value =  ".*Access has been granted"
test("visible").value = True
test("html tag").value = "A"

Set applicationitems = browser("creationtime:=0").Page("micclass:=Page").ChildObjects(test)

If applicationitems.count = 0 Then
    ' Nothing is checked
else
    For i = 0 to applicationitems.count - 1
        applicationitems(i).click
        wait(2)
    Next
End If



Set test = description.Create    
test("micclass").value = "WebElement"
test("acc_name").value =  ".*Access has been removed"
test("visible").value = True
test("html tag").value = "A"

Set applicationitems = browser("creationtime:=0").Page("micclass:=Page").ChildObjects(test)

expectedCount = applicationitems.count

For i = 0 to applicationitems.count - 1
    applicationitems(i).click
    wait(2)
Next



Set test = description.Create    
test("micclass").value = "WebElement"
test("acc_name").value =  ".*Access has been granted"
test("visible").value = True
test("html tag").value = "A"

Set applicationitems = browser("creationtime:=0").Page("micclass:=Page").ChildObjects(test)

If applicationitems.count = expectedCount Then
'    msgbox "Passed!"
    
'else
'    msgbox "Failed!"
'End If

    RESULTS.InsertResult GLOBAL_STEP_DESCRIPTION,"Granting application access","Granting application access - Success" ,"PASS"
else
    RESULTS.InsertResult GLOBAL_STEP_DESCRIPTION,"Granting application access","Granting application access - Error" ,"FAIL"
End if

End Function