天天看點

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