我目前正在使用UFT --我有一个GUI测试,我想删除/更新其中一个测试中的web element对象,但我担心它会被我们测试套件中的另一个测试引用。(我正在进入别人构建的测试套件)
有没有办法判断对象存储库中的某个对象是否正在其他测试中使用?(不需要进入每个单独的测试和操作来找出答案?)
发布于 2017-10-31 11:09:45
我的方法是简单的递归文件搜索。
发布于 2018-01-19 23:00:27
您可以使用来自用友的Search>View>Find (或ctrl+F),并选择查看整个解决方案
发布于 2018-01-21 02:40:22
从每个操作中打开"Script.mts“文件,并搜索您的对象名称。如果找到对象,请将对象所在的脚本名和行号写在一个文件中。
使用以下代码:
'strScriptsPath is the path where your test script folders are placed.
Set strScripts = objFSO.GetFolder(strScriptsPath).SubFolders
For Each Script In strScripts
strAction = strScriptsPath & "\" & Script.Name & "\Action1\Script.mts"
If objFSO.FileExists(strAction) Then
'Open Script in NotePad
Set strFile = objFSO.OpenTextFile(strAction, 1)
Do While Not (strFile.AtEndOfStream)
strLine = strFile.ReadLine
If InStr(1, strLine, strObjectName) > 0 Then
iVerificationCount = objSheet.UsedRange.Rows.Count
iCurrentRow = iVerificationCount + 1
objSheet.Cells(iCurrentRow, 1) = Script.Name
objSheet.Cells(iCurrentRow, 2) = strLine
If strFile.AtEndOfStream Then
objSheet.Cells(iCurrentRow, 3) = strFile.Line
Else
objSheet.Cells(iCurrentRow, 3) = strFile.Line - 1
End If
End If
Loop
strFile.Close
Set strFile = Nothing
End If
Next
Set strScripts = Nothing为了能够使用此代码,请声明objFSO对象并编写一段代码来创建excel并获取objSheet。
您还可以使用以下代码替换对象名称:
如上所述,使用For Each循环
strScript = strScriptsPath & "\" & strScriptName & "\Action1\Script.mts"
strFind = "Old Object Name"
strReplace = "New Object Name"
Set strFile = objFSO.OpenTextFile(strScript, 1)
strData = strFile.ReadAll
strNewData = Replace(strData, strFind, strReplace)
strFile.Close
Set strFile = Nothing
Set strFile = objFSO.OpenTextFile(strScript, 2)
strFile.Write strNewData
strFile.Close
Set strFile = Nothing**你只需要把整个代码写在一个.vbs文件中,然后运行这个文件。
https://stackoverflow.com/questions/47025242
复制相似问题