我在 UFT 中使用描述性编程。在播放过程中,我想检查 Windows 打印对话框是否出现。然后我想单击该对话框中的取消按钮。 我的问题:偶尔 QTP 无法识别打印对话框,因此单击取消按钮失败。 这怎么可能时而失败,时而成功?
我的代码语法如下:
Set Window_EnterMeter = browser_servicemanager.Window("regexpwndtitle:=Enter Meters.*")
Set dialog_Print = Window_EnterMeter.Dialog("regexpwndtitle:=Print")
Set winbtn_CalcelPrint = dialog_Print.WinButton("regexpwndtitle:=Cancel")
fn chckprintpopupwndow()
{ ''''''''Navigating to that page
call Absolutehighlight(Button_Action)
call Absolutehighlight(Meter_Entry)
call Absolutehighlight(PrintMeter_Opt2)
AbsoluteClick(PrintMeter_Opt2)
EnterMeters_Window.WebElement("html id:=ctl00_Save_BTN_C").Click
'''''''By click on abve option window popup print option appears and UFT not identifying that window all times, so clicking on cancel button not doing so TC fails
dialog_Print.Activate
AbsoluteClick(winbtn_CalcelPrint)
EnterMeters_Window.WebElement("html id:=ctl00_Cancel_BTN_C").Click
}
最佳答案
我找到了这个问题的根本原因,实际上是在虚拟机 (VM) 中运行整个脚本。在某些回放过程中,我最小化了 VM 并在本地系统上工作,因此在最小化过程中 UFT 无法检测到 winobject,并且在最小化模式下也不会处理(发送键)任何按键事件。我们可以通过更新注册表编辑来解决最小化问题。有关详细信息,请访问:- can we execute QTP script on remote machine by keeping session minimized
关于testing - UFT 未在某些播放中识别窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19075725/