软件测试论坛

 找回密码
 软件测试论坛注册页
查看: 497|回复: 1

咨询一个win7下silktest取不到计算器结果的问题

[复制链接]
发表于 2014-4-3 15:55:14 | 显示全部楼层 |阅读模式
软件测试工程师就业班马上开班
刚刚开始学习使用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!!!


ISTQB
 楼主| 发表于 2014-4-3 16:07:26 | 显示全部楼层
软件测试工程师就业班马上开班
脚本录制时按钮的代码是:
//数字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]"
后执行不报错
ISTQB

本版积分规则

Archiver|手机版|小黑屋|领测软件测试网 ( 京ICP备10010545号-5 )

GMT+8, 2021-10-23 13:48 , Processed in 0.143129 second(s), 11 queries , Xcache On.

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表