Record your first action

This exercise describes how to record UFT test steps to log in to your account on the AdvantageDEMO site.

Record steps to log in to your account

This procedure describes how to record an action in UFT.

Do the following:

  1. In Chrome, open the AdvantageDEMO site. If you are still logged in from the earlier steps, log out of the site.

    Click the USER menu at the top right, and then click Sign out.

  2. In UFT, select Record > Record and Run Settings. On the Web tab, select Record and run on any open browser. Click OK, and save your test.
  3. Double-click the Login action to open it, and then click the Record toolbar button .

    UFT is hidden so that you can see your browser window, and the Recording toolbar appears.

  4. In Chrome, perform the following steps to log in to your account:

    1. Click the user icon at the top right to display the Sign In dialog.

    2. Populate the Username and Password fields using the credentials you created in Analyze your app.

      Note: The examples in this tutorial use the credentials for Mary Sanchez, a fictional devtester. Your code will look slightly different, and show your credentials instead.

    3. Click SIGN IN.

  5. On the recording toolbar, click Stop to return to UFT.

Back to top

Your steps in the Editor

By default, UFT displays your steps in the Editor. Your steps should look like this:

Browser("Advantage Shopping").Page("Advantage Shopping").Link("My account My orders Sign").Click

Browser("Advantage Shopping").Page("Advantage Shopping").WebEdit("username").Set "msanchez"

Browser("Advantage Shopping").Page("Advantage Shopping").WebElement("Password").Click

Browser("Advantage Shopping").Page("Advantage Shopping").WebEdit("password").SetSecure "5b7d01c46ef781c0d935074e5350e2bd506ab3f206a17fc2"

Browser("Advantage Shopping").Page("Advantage Shopping").WebButton("sign_in_btnundefined").Click

Tip: UFT automatically encrypts your password and uses a SetSecure method in the fourth step to enter the value.

You can also manually encrypt passwords for use in UFT tests, using the UFT Password Encoder tool, and will do so later on in this tutorial.

For details, see Add values to your text field steps and Password Encoder Tool.

Add wait steps to make your test run smoother

Add wait steps to enable UFT to pause the test run and wait for your browser to load. This is an optional, but recommended step that is helpful on slower machines and wireless connections.

Do the following:

  1. Add the following line at the top of your script: wait 3
  2. Add the following line before the last step in your script: wait 2

Your code should now look like this:

wait 3

Browser("Advantage Shopping").Page("Advantage Shopping").Link("Link").Click

Browser("Advantage Shopping").Page("Advantage Shopping").WebEdit("username").Set "msanchez"

Browser("Advantage Shopping").Page("Advantage Shopping").WebElement("Password").Click

Browser("Advantage Shopping").Page("Advantage Shopping").WebEdit("password").SetSecure "5b7d01c46ef781c0d935074e5350e2bd506ab3f206a17fc2"

wait 2

Browser("Advantage Shopping").Page("Advantage Shopping").WebButton("sign_in_btnundefined").Click

Back to top

Your steps in the Keyword View

The Keyword View displays the steps in your action in a hierarchical list.

In the UFT toolbar, click the Toggle between ... Keyword View ... Editor button to switch to the Keyword View.

The Keyword View displays the steps in the following columns:

Item The test object on which a step is performed
Operation The method, or operation performed in this step.
Value

Any values defined for the method in this step.

For example, you'll see the values you defined in the account fields in this column.

Documentation A human-readable description of the action performed in this step.

Your Keyword View should look like this:

Back to top

Next steps: