QTP基本使用——associate actions

用实例来说话

E.g 现在有一个登陆框 , 点击button “Help”查询登陆密码, 确定后输入账号密码 , 然后登陆 系统,最后关闭

其一: Check the Help about this system.

1) Dialog("Login").WinButton("Help").Click // 点击Dialog “Login”上面的 WinButton "Help"
2) If  Dialog("Login").Dialog("Flight Reservations").Exist Then  //如果Dialog "Flight Reservations"存在, 则执行下面的操作
      Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click  //click the button "确定"
    End If

 

其二: put in the agent name and password, then close the window.

3) Dialog("Login").WinEdit("Agent Name:").Set "mercury"  //Agent name is set as "mercury"
4) Dialog("Login").WinEdit("Password:").SetSecure "4b892adbc75260f617acbe3e950f7551b440f709" //set the password which is encrypted.
5) Dialog("Login").WinButton("OK").Click //Click the button "OK"
6) Window("Flight Reservation").Close  //Close the window "Flight Reservation"

 

PS: 可以将其一分离成为通用的action, 那么在调用它的时候就需要进行关联

First : create new action(action_help)

Step 1: Insert -> Call to new action. Input action_help.

Step 2: Click with RSK and select Action properties. Then select "Reusable action".

 

Second : associate the action

Step 1: Save all the actions. Resources -> Object Repository -> File -> Export Local Objects.

Step 2: Set the association. Resources-> Associate Repositories -> Add repository.

 

Now set the  available actions and associated actions

 

 

你可能感兴趣的:(insert,dialog,action,button,login,resources)