Global和local的区别

QTP中Datatable部分是由两部分组成的:Global表和对应于每个Action的local表。
Global表就是指全局的表,对每个Action都起作用;
Action表只对这个Action本身起作用,每个Action都有一个对于本身Action的表;
计算整个程序跑多少次的时候是通过Datatable中Global需要跑的次数乘以Action中的需要跑的次数。
例如Action1里有4条数据需要跑
1.如果gobal设置循环一次,action循环所有的,那么此时把action中所有数据取出
2.如果goble和action设置循环都只是一次,那么此时就只取action的第一条数据
3.gobal不受action的设置的影响



   这是代码控制action

 

Dim i,currentValue 
  i = 1 
  While i<= 3
      Rem    To find the value, you dan apply  any  of   the following  two  fuctions :
      Rem     DataTable.Value(ParameterID [, SheetID])     or     DataTable(ParameterID [, SheetID]) 

       currentValue =  DataTable.Value("LProductInfo","Action1")
          Rem currentValue =   DataTable("LProductInfo","Action1")
          
            Browser("Login Page").Page("Page_3").Image("spacer").FireEvent "onmouseover"
            Browser("Login Page").Page("Page_3").Image("spacer").Click
            Browser("Login Page").Page("Page_4").WebButton("Create").Click
            Browser("Login Page").Page("Page_5").WebEdit("#form.name").Set currentValue
            Browser("Login Page").Page("Page_5").WebEdit("#form.productNo").Set currentValue
            Browser("Login Page").Page("Page_5").WebEdit("#form.spec").Set currentValue
            Browser("Login Page").Page("Page_5").WebEdit("#form.unit").Set currentValue
            Browser("Login Page").Page("Page_5").WebButton("Save").Click
            wait(2)
             DataTable.GetSheet("Action1").SetNextRow
            i = i+1
  Wend

猜你喜欢

转载自284772894.iteye.com/blog/2163910