51Testing软件测试论坛
标题:
咨询一个win7下silktest取不到计算器结果的问题
[打印本页]
作者:
tigaryang
时间:
2014-4-3 16:52
标题:
咨询一个win7下silktest取不到计算器结果的问题
刚刚开始学习使用silktest,请大神帮忙解决一下这个问题。
试验中取不到计算器文本框中的数据。
inframe.inc内容如下:
[ ] const wDynamicMainWindow = 计算器
[ ]
[-] window MainWin 计算器
[ ] locator "/MainWin[@caption='计算器']"
[ ]
[ ] // The working directory of the application when it is invoked
[ ] const sDir = "C:\Windows\system32"
[ ]
[ ] // The command line used to invoke the application
[ ] const sCmdLine = "C:\Windows\system32\calc.exe"
[ ]
[ ] // The list of windows the recovery system is to leave open
[ ] // const lwLeaveOpenWindows = {?}
[ ] // const lsLeaveOpenLocators = {?}
[+] Menu 查看V
[ ] locator "查看(V)"
[+] MenuItem 标准型T
[ ] locator "标准型(T)"
[ ] //复位按钮C
[-] PushButton ButtonC
[ ] locator "[13]"
[ ] //数字按钮1
[-] PushButton Number1
[ ] locator "[5]"
[ ] //操作按钮+
[-] PushButton Plus
[ ] locator "[23]"
[ ] //数字按钮2
[-] PushButton Number2
[ ] locator "[11]"
[ ] //操作按钮=
[-] PushButton Equals
[ ] locator "[28]"
[-] StaticText CalResult
[ ] locator ""
测试脚本文件内容:
[-] testcase Test1 () appstate PrepareCal
[ ] String sResultValue = Plus()
[ ] print("sResultValue is {sResultValue}")
[ ] Verify(val(sResultValue) , 0,"Expect 1+2=3, actually it is {sResultValue}")
[ ] print ("The End!!!")
[-] String Plus()
[ ] 计算器.Number1.Click()
[ ] String number1 = 计算器.CalResult.GetText()
[ ] Print(" number1 is {number1}")
[ ] 计算器.Plus.Click()
[ ] 计算器.Number2.Click()
[ ] String number2 = 计算器.CalResult.GetText()
[ ] Print(" number2 is {number2}")
[ ] 计算器.Equals.Click()
[ ] String expectResult = number1+number2
[ ] Print(" expectResult is {expectResult}")
[ ] String sResultValue = 计算器.CalResult.GetText()
[ ] return sResultValue
[-] appstate MyCalBaseState() basedon DefaultBaseState
[-] if(计算器.Exists())
[ ] 计算器.Close()
[-] appstate PrepareCal() basedon MyCalBaseState
[ ] 计算器.invoke()
[ ] 计算器.ButtonC.Click()
[ ]
执行结果如下:
[ ] Script test.t - Passed
[ ] Machine: (local)
[ ] Started: 03:23:05PM on 03-Apr-2014
[ ] Elapsed: 0:00:07
[ ] Passed: 1 test (100%)
[ ] Failed: 0 tests (0%)
[ ] Totals: 1 test, 0 errors, 0 warnings
[ ]
[-] Testcase Test1 - Passed
[ ] number1 is
[ ] number2 is
[ ] expectResult is
[ ] sResultValue is
[ ] The End!!!
脚本录制时按钮的代码是:
//数字1的按钮
[-] PushButton Number1
[ ] locator "[@priorlabel='0'][5]"
但直接执行报错:
[-] Testcase Test1 - 1 error
[ ] Failed to resolve object '/MainWin[@caption='计算器'] -> //PushButton[@priorlabel='0'][5]'.
[ ] Occurred in Click
[ ] Called from Test1 at plusTest.t(4)
修改为
[-] PushButton Number1
[ ] locator "[5]"
后执行不报错
作者:
tigaryang
时间:
2014-4-4 10:44
怎么没有大神帮忙解决啊
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2