【问题标题】:My UFT code cannot identify browser/parent object. Keep getting 'cannot find objects parent'我的 UFT 代码无法识别浏览器/父对象。不断收到'找不到对象父'
【发布时间】:2018-09-04 04:51:37
【问题描述】:

我是一名软件自动化专业的学生,​​并且是编程新手。我只写了大约几个星期的代码。我用的自动化工具是UFT,语言是VB脚本

当我在 UFT 中编写脚本时,有时会遇到此错误:


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

我知道这意味着 UFT 无法识别浏览器或页面。我不知道是为什么。我以为我正确地编写了代码。我什至在浏览器和页面中添加了创建时间和标题以更好地识别它。

谁能帮我解决这个错误?

这是我的整个脚本。很短,只有 54 行。


选项显式

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

【问题讨论】:

    标签: vbscript hp-uft


    【解决方案1】:

    Page("micclass:=Browser") 这是错误的。 Page 类型的 Object 也不能​​是 Browser 类型。 (micclass是Object的类型)

    如果您不想在对象存储库层次结构中使用它们,只需使用 index:=0 来识别页面

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-08
      • 1970-01-01
      • 2015-11-12
      • 1970-01-01
      • 1970-01-01
      • 2021-03-17
      • 2011-11-17
      • 1970-01-01
      相关资源
      最近更新 更多