但是,您的问题是:"Is it possible"和 - yes, it is possible, for example if you apply the receipt used to create a dynamic RunAction routine. There is no documented or ready-to-use solution as of yet, though.
Dim iCount
If Not oWorkBook Is Nothing Then
For iCount = 1 To oWorkBook.WorkSheets.Count
If Trim(UCase(sSheet)) = Trim(UCase(oWorkBook.Worksheets(iCount).Name)) Then
ExcelWorkSheetExists = Cint(iCount)
Exit Function
End If
Next
ExcelWorkSheetExists = False
Else
ReportEvent "warning", "ExcelWorkSheetExists:oWorkBook Object is not current set", "ExcelWorkSheetExists:oWorkBook Object is not current set", False
ExcelWorkSheetExists = False
End If
2 回答
There is no documented way to do this.
这并不意味着它是不可能的,只是没有人知道如何,至少:尚未 .
它与我们在
LoadAndRunAction
不存在时的情况相当 . 可以采用此函数的静态版本RunAction
,这需要在设计时出现目标操作,并用您真正想要调用的操作替换(在运行时)其目标操作 .这当然涉及使用您真正想要调用的操作的文件修补
RunAction
目标操作的文件,因此当有关内部数据格式和位置的技术细节从UFT版本更改为UFT发布(不太可能发生) .由于没有“
LoadAndRun
-style”动态RunAPITest
例程,您可以应用相同的技术:在设计时:
RunAPITest
调用某些API测试在运行时(当然是以编程方式):
将API测试文件替换为您真正要调用的API测试文件(可能通过复制它们)
执行
RunAPITest
调用 .如果您的工件存储在QC / ALM中而不存储在文件系统中,则整个过程会变得更复杂 . 您需要修改正确的数据库内容以替换API测试的内容,这可能不是一项简单的任务 .
但是,您的问题是:"Is it possible"和 - yes, it is possible, for example if you apply the receipt used to create a dynamic RunAction routine. There is no documented or ready-to-use solution as of yet, though.
**附录 - 顺便说一句,对于BPT组件,存在同样的困境 . 在运行时,不可能指定要执行的组件,也不可能从组件中调用组件,既不能绑定“静态”也不能“动态” . 由于无法在文件系统中存储组件,因此必须对数据库进行“JIT-patch”以模拟动态组件调用 .
公共函数ExcelWorkSheetExists(oWorkBook,sSheet)
结束功能