I am a software automation student and new to programming. I have only been writing code for about a few weeks. The automation tool I'm using is UFT and the language is VB script
When I write scripts in UFT I sometimes come across this error:
Cannot find the "[ WebList ]" object's parent "[ Browser ]" (class Browser). Verify that parent properties match an object currently displayed in your application.
Line (32): "Browser("micclass:=Browser", "CreationTime:=0", "Title:=.*").Page("micclass:=Browser", "CreationTime:=0", "Title:=.*").WebList("html id:=state", "html tag:=SELECT").Select State".
I know it means UFT cannot identify browser or page. What I don't know is why. I thought I wrote the code correctly. I even added creationtime and title in browser and page to better identify it.
Can anyone help me fix this error?
Here's my entire script. It's short, only 54 lines.
Option Explicit
Dim MyExcel, MySheet, RowCount, i ,IE, URL, State, PayType, Pay, PayFrequency, MaritalStatus, WithholdingAllowances, AdditionalWithholding, Allowances, AdditionalWithholding2, ActualCheckValue, ExpectedCheckValue, CapturedTaxRate
Set MyExcel = CreateObject ("Excel.Application")
MyExcel.Workbooks.Open "C:\Users\PIIT\Documents\Excel Docs\In Class Assigment - 7.xlsx"
Set MySheet = MyExcel.ActiveWorkbook.WorkSheets ("Sheet1")
IE = "iexplore.exe"
URL = "suburbancomputer.com/tips_calculator.php"
SystemUtil.CloseProcessByName IE
SystemUtil.Run IE, URL
wait 5
RowCount = MySheet.UsedRange.Rows.Count
For i = 2 To RowCount
State = MySheet.Cells(i,"A")
PayType = MySheet.Cells(i,"B")
Pay = MySheet.Cells(i,"C")
PayFrequency = MySheet.Cells(i,"D")
MaritalStatus = MySheet.Cells(i,"E")
WithholdingAllowances = MySheet.Cells(i,"F")
AdditionalWithholding = MySheet.Cells(i,"G")
Allowances = MySheet.Cells(i,"H")
AdditionalWithholding2 = MySheet.Cells(i,"I")
ActualCheckValue = MySheet.Cells(i,"J")
Browser("micclass:=Browser", "CreationTime:=0", "Title:=.*").Page("micclass:=Browser", "CreationTime:=0", "Title:=.*").WebList("html id:=state", "html tag:=SELECT").Select State
Browser("micclass:=Browser", "CreationTime:=0", "Title:=.*").Page("micclass:=Browser", "CreationTime:=0", "Title:=.*").WebList("innertext:=Salary Hourly ", "html tag:=SELECT").Select PayType
Browser("micclass:=Browser", "CreationTime:=0", "Title:=.*").Page("micclass:=Browser", "CreationTime:=0", "Title:=.*").WebEdit("html id:=salary", "html tag:=INPUT").Set Pay
Browser("micclass:=Browser", "CreationTime:=0", "Title:=.*").Page("micclass:=Browser", "CreationTime:=0", "Title:=.*").WebList("html id:=ppy", "html tag:=SELECT").Select PayFrequency
Browser("micclass:=Browser", "CreationTime:=0", "Title:=.*").Page("micclass:=Browser", "CreationTime:=0", "Title:=.*").WebList("html id:=fit_marital_status", "html tag:=SELECT").Select MaritalStatus
Browser("micclass:=Browser", "CreationTime:=0", "Title:=.*").Page("micclass:=Browser", "CreationTime:=0", "Title:=.*").WebList("html id:=fit_dependent", "html tag:=SELECT").Select WithholdingAllowences
Browser("micclass:=Browser", "CreationTime:=0", "Title:=.*").Page("micclass:=Browser", "CreationTime:=0", "Title:=.*").WebEdit("html id:=fit_addon", "html tag:=INPUT").Set AdditionalWithholdings
Browser("micclass:=Browser", "CreationTime:=0", "Title:=.*").Page("micclass:=Browser", "CreationTime:=0", "Title:=.*").WebList("html id:=state_dependent", "html tag:=SELECT").Select Allowences
Browser("micclass:=Browser", "CreationTime:=0", "Title:=.*").Page("micclass:=Browser", "CreationTime:=0", "Title:=.*").WebEdit("html id:=state_addon", "html tag:=INPUT").Set AdditionalWithholding2
Browser("micclass:=Browser", "CreationTime:=0", "Title:=.*").Page("micclass:=Browser", "CreationTime:=0", "Title:=.*").WebButton("name:=Calculate Paycheck", "class:=nav_button").Click
wait 2
ActualCheckValue = Browser("micclass:=Browser").Page("micclass:=Page").Page("micclass:=Page").WebElement("html tag:=B", "index:=16").GetROProperty("innerhtml")
Print ActualCheckValue
Browser("micclass:=Browser").Page("micclass:=Page").Page("micclass:=Page").Link("html id:=ui-id-3", "innerhtml:=Effective Rate").Click
CapturedTaxRate = Browser("micclass:=Browser").Page("micclass:=Page").Page("micclass:=Page").WebElement("html tag:=B", "index:=21").GetROProperty("innerhtml")
Print CapturedTaxRate
Browser("micclass:=Browser").Page("micclass:=Page").Page("micclass:=Page").Link("html id:=ui-id-1", "innerhtml:=Enter").Click
Next