Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vbscript 我的UFT代码无法识别浏览器/父对象。继续获取“找不到父对象”_Vbscript_Hp Uft - Fatal编程技术网

Vbscript 我的UFT代码无法识别浏览器/父对象。继续获取“找不到父对象”

Vbscript 我的UFT代码无法识别浏览器/父对象。继续获取“找不到父对象”,vbscript,hp-uft,Vbscript,Hp Uft,我是一名软件自动化专业的学生,对编程一无所知。我只写了几个星期的代码。我使用的自动化工具是UFT,语言是VB脚本 当我在UFT中编写脚本时,有时会遇到以下错误: 我知道这意味着UFT无法识别浏览器或页面。我不知道为什么。我认为我写的代码是正确的。我甚至在浏览器和页面中添加了creationtime和title以更好地识别它 有人能帮我纠正这个错误吗 这是我的全部剧本。它很短,只有54行 选项显式 Dim MyExcel, MySheet, RowCount, i ,IE, URL, State,

我是一名软件自动化专业的学生,对编程一无所知。我只写了几个星期的代码。我使用的自动化工具是UFT,语言是VB脚本

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

我知道这意味着UFT无法识别浏览器或页面。我不知道为什么。我认为我写的代码是正确的。我甚至在浏览器和页面中添加了creationtime和title以更好地识别它

有人能帮我纠正这个错误吗

这是我的全部剧本。它很短,只有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

Pagemicclass:=浏览器这是错误的。Page类型的对象不能同时为Browser类型。micclass是对象的类型

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

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