Add Checkout steps using AI Inspection

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

Add steps to check out your cart

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

Do the following:

  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 Inspection window.

    In the AI 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.
  4. Re-inspect the application.

  5. Check whether the price for your order is correct, using the GetValue method. Do the following:

    1. In the AI 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.

  6. 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 Inspection window to add the corresponding step to the Editor.

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

  8. 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: