SilkTest2010 Open Agent学习笔记-1
上一篇 / 下一篇 2010-12-18 05:49:01 / 个人分类:SilkTest
//frame.Inc文件中加入如下2行,就可以在.t文件中用sleep(LONG_SLEEP)或者sleep(SHORT_SLEEP)来控制所有的等待时间。如果程序比较慢,就可以直接在frame.inc中修改参数
INTEGER LONG_SLEEP = 5
DOUBLE SHORT_SLEEP = 2.5
// .t文件开头写上use,就可以使用此frame.inc文件作为预设环境
use "Frame.inc"
//把browser窗口激活并显示在屏幕前
WebBrowser.SetActive()
//判断browser是否存在,如果不存在就打开预设的browser
if !(WebBrowser.Exists())
WebBrowser.Invoke()
//如果"Patient" button在10秒钟内不显示,LogError and LogWarning发出错信息.只有出错的时候才显示logerror和logwarning中的文字
testcase log_error_warning () appstate ApplicationOpen
if ! (Desktop.find("/BrowserApplication//BrowserWindow//FlexApplication[@caption='GlobeMed']//FlexButton[@caption='Patient']", {10, false}) !=NULL)
LogError ("this window is not found")
LogWarning("this window might not be correct, WARNING!")
else
Print ("Patient button is existing")
//显示i=1, i+1知道满足i<5的条件,打印i, i显示1 2 3 4
[-] testcase print_number ()
[ ] Int i=1
[ ] for (;i<5;i=i+1)
[ ] Print (i)
//显示i+2知道满足1<9,打印i
[-] testcase Excerise_1 () //appstate none
[ ] INTEGER i = 0
[ ] for i = 2 to 9 step 2
[ ] Print(i)
//显示1 3 5 7 9
[-] testcase calc() appstate none
[ ] int i=1
[-] for (;i<10;i=i+2)
[ ] Print ("{i}")
//Input test1 to test10 in the UserID text field
Int i=1
for (;i<10);i++)
desktop.find("/BrowserApplication//BrowserWindow//FlexApplication[@caption='GlobeMed']//FlexTextArea[@caption='User Name:userId']").input("test{i}")
//type test1 to test10
desktop.find("/BrowserApplication//BrowserWindow//FlexApplication[@caption='GlobeMed']//FlexTextArea[@caption='User Name:userId']").Typekeys("test{i}")
//输出打印flex中userId editbox中的text
Print (Desktop.Find("/BrowserApplication//BrowserWindow//FlexApplication[@caption='GlobeMed']//FlexTextArea[@caption='User Name:userId']").text)
Desktop.Find("/BrowserApplication//BrowserWindow//FlexApplication[@caption='GlobeMed']//FlexTextArea[@caption='User Name:userId']").Typekeys("<Home><Shift-End><DELETE>")
[-] TestVerification (STRING sExpectedValue, STRING sTestValue)
[-] if ( sExpectedValue == sTestValue )
[ ] Print ("Test was successful")
[-] else
[ ] raise 1 , "ERROR: Test verification failed"
[ ] return
[-] ErrorHandler ()
[ ] Print (ExceptData()) // Continue with testcase
[ ] return
[-] testcase do_except_example ()
[ ] STRING sTestValue = "xxx"
[ ] STRING sExpectedValue = "yyy"
[-] do
[ ] TestVerification (sExpectedValue,sTestValue)
[-] except
[ ] ErrorHandler ()
//Exception function:logs an exception to a results file.
TAG: