51Testing软件测试论坛

标题: FOR循环如何像Global中设置参数一样使得整个脚本循环运行? [打印本页]

作者: pxwcypx    时间: 2007-10-25 12:18
标题: FOR循环如何像Global中设置参数一样使得整个脚本循环运行?
d=array("@","`","!","%","*")
          For j=0 to 4
       msgbox d(j)
    wait 3
With Browser("欢迎使用 KJLINK CRM系统")
wait 3
With .Page("欢迎使用 KJLINK CRM系统")
wait 3
  .WebEdit("tbxUserName").Set "admin"
  .WebEdit("tbxPassword").SetSecure "471dc7c9c3addee5bea254a0"
  .Image("ImgBtnLogin").Click 2,6
End With
.Page("Untitled Page").Link("我的任务").Click
  
.Page("Untitled Page_2").Image("ctl00$ContentPlaceHolder1$imgb").Click 11,8
With .Page("Untitled Page_3")
  .WebList("ctl00$ContentPlaceHolder1$drop").Select "上级决定"
  .WebList("ctl00$ContentPlaceHolder1$drop_2").Select "完成"
    .Image("ctl00$ContentPlaceHolder1$imgb").Click 18,11
    wait 3
Browser("Runtime Error").Back
msgbox"请将必填项输入完整",48,"必填项检查"
'Browser("Runtime Error").Page("Untitled Page")'.Sync
'  .Image("ctl00$ContentPlaceHolder1$imgb_2").Click 33,6
  '.Image("ctl00$ContentPlaceHolder1$imgb_2").Click 29,11
  .WebEdit("ctl00$ContentPlaceHolder1$tbxB").Set "2007-10-12"
      .Image("ctl00$ContentPlaceHolder1$imgb").Click 18,11
    wait 3
Browser("Runtime Error").Back
msgbox"请将必填项输入完整",48,"必填项检查"
  .WebEdit("ctl00$ContentPlaceHolder1$tbxE").Set "2007-10-15"
   .WebEdit("ctl00$ContentPlaceHolder1$tbxN").Set "qq163"'DataTable("rwmc", dtGlobalSheet)
   .WebList("ctl00$ContentPlaceHolder1$drop_3").Select "高"'DataTable("figng", dtGlobalSheet)
     
       'string i = string.Empty
     ' c="我"
      '      for j=0 to 9
         
               
            '    i = i + c
               
      '   next  
  
            'textBox1.Text = i;
  '.WebEdit("ctl00$ContentPlaceHolder1$tbxP").Set  i
   
            
     .WebEdit("ctl00$ContentPlaceHolder1$tbxR").Set d(j)'"qeqreqwrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"
     wait 3
            
  
  .Image("ctl00$ContentPlaceHolder1$imgb").Click 18,11
  .Image("ctl00$ContentPlaceHolder1$imgb_2").Click 33,6
  .Image("ctl00$ContentPlaceHolder1$imgb_2").Click 29,11
   
   
End With
With .Page("Untitled Page_2")

wait 3
  .WebList("ctl00$ContentPlaceHolder1$ddlC").Select "20"
'.Sync
Browser("欢迎使用 KJLINK CRM系统").Close
   'wait 2
  '   wait 3
  '.WebList("ctl00$ContentPlaceHolder1$ddlP").Select 2
  '  .Sync
  wait 1
End With
End With
Next
-----------------------------------------------------------------------------------------------
我想检查-》添加“我的任务”页面中的某个输入框中输入我预先设定在数组中的非法字符,通过FOR循环第二、三。。。次循环登录后,添加“我的任务”页面中其他的输入项的输入值不变,要求对检查项循环输入(@,!,#,%,`)按顺序取一个值这样来检查每一个非法值在提交后页面有什么变化,但是我到了第二次循环就走不下去了,希望哪位大哥大姐帮帮小弟:在此谢过!
作者: pxwcypx    时间: 2007-10-25 13:05
[attach]34396[/attach]
第二次循环就出现这样的错误提示!
作者: scorix    时间: 2007-10-25 15:03
系统让你给关掉了,找不到对象当然要报错了
作者: pxwcypx    时间: 2007-10-25 15:27
可,可,可是我不关闭也一样啊,所以我想关闭看看可以不,结果还是不行啊
作者: hsjzfling    时间: 2007-10-25 19:45
在你的脚本开头加上一个打开IE并导航到被测系统的地址的语句就可以了
作者: pxwcypx    时间: 2007-10-26 09:36
不太明白hsjzfling的意思,在开头加好像不管用,下面的循环都是从FOR循环处开始执行的啊,能举个简单的例子吗谢谢啦
作者: hsjzfling    时间: 2007-10-26 10:11
d=array("@","`","!","%","*")
          For j=0 to 4
       msgbox d(j)
    wait 3

SystemUtil.CloseProcessByName "iexplore.exe"
SystemUtil.Run "iexplore.exe","KJLINK CRM系统的网址",,,3   '在第二个参数中填入网址
With Browser("欢迎使用 KJLINK CRM系统")


还有尽量注意代码的格式,让代码看起来层次分明。
作者: hsjzfling    时间: 2007-10-26 10:12
d=array("@","`","!","%","*")
          For j=0 to 4
       msgbox d(j)
    wait 3

SystemUtil.CloseProcessByName "iexplore.exe"
SystemUtil.Run "iexplore.exe","KJLINK CRM系统的网址",,,3   '在第二个参数中填入网址
With Browser("欢迎使用 KJLINK CRM系统")


还有尽量注意代码的格式,让代码看起来层次分明。
作者: pxwcypx    时间: 2007-10-26 10:32
再次感谢hsjzfling,呵呵问题解决了!
作者: 5555    时间: 2007-10-26 11:37
不错,学习了~




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2