Add Checkout steps using AI Object Inspection

This exercise describes how to edit AI-based steps added through AI Object Inspection and extend test capabilities by using AI-based methods.

Add steps to check out your cart

This procedure describes how to use AI Object Inspection to add steps that check out your cart.

To add check out steps:

  1. In UFT One, open the Checkout action, either from the Solution Explorer, or the canvas.

  2. After you click the ADD TO CART button on the HP CHROMEBOOK 14 G1 (ENERGY STAR) details page, re-inspect the page in the AI Object Inspection window.

    In the AI Object Inspection window, click the highlighted CHECKOUT ($299.99) button. Then click the Add to test button to add the step that clicks the CHECKOUT ($299.99) button to the Editor.

  3. Go to the inspected application and click the CHECKOUT ($299.99) button to navigate to the ORDER PAYMENT page.

    Re-inspect the application.

     

  4. Check whether the price for your order is correct, using the GetValue method:

    1. In the AI Object Inspection window, click the total price $299.99. In the pop-up dialog box that opens, click Add to test. The following syntax is added to your Editor:

      AIUtil.FindTextBlock("$299.99", micFromBottom, 1).Click

    2. Replace the Click method with GetValue and add an "If/Then" statement. For example:

      price = AIUtil.FindTextBlock("$299.99", micFromBottom, 1).GetValue
      If price <> "$299.99" Then
      	Reporter.ReportEvent micFail, "unexpected price, value: " & price, price
      End If

    For more AI object methods, see the AI-based testing section of the UFT One Object Model Reference for GUI Testing.

  5. Continue to create steps about shipping and payment details.

    The default shipping address is United States on this site. Directly click the Next button in the AI Object Inspection window to add the corresponding step to the Editor.

  6. Go to the inspected application, click Next to show the Payment Method tab page, and then return to the AI Object Inspection window to do a re-inspection.

  7. Click SafePay radio button, SafePay name input, SafePay password, and PAY NOW button sequentially to add the payment settings steps to the Editor.

    For SafePay name input and SafePay password, you need to type the values in the object description.

Back to top

View your steps in the Editor View

When you're done adding steps to this action, the entire Checkout action should look like this:

AIUtil("button", "CHECKOUT ($299.99)").Click
price = AIUtil.FindTextBlock("$299.99", micFromBottom, 1).GetValue
If price <> "$299.99" Then
	Reporter.ReportEvent micFail, "unexpected price, value: " & price, price
End If
AIUtil("button", "NEXT").Click
AIUtil("radio_button", "SafePay").SetState "On"
AIUtil("input", "SafePay username").Type "Aidemo"
AIUtil("input", "SafePay password").Type "Sa12345"
AIUtil("button", "PAY NOW").Click

Back to top

Next steps: