Exercise 1: Create an account

This exercise guides you through automating the process of creating a new Advantage Online Shopping account using LeanFT.

Step 1: Launch your IDE

Start by launching the supported IDE of your choice. Once the IDE is open, notice:

  • The LeanFT icon in your system tray. This indicates that the LeanFT runtime engine is launched.

  • The LeanFT menu in your IDE. Use this menu to access the Object Identification Center (OIC), HPE Mobile Center, run results, and more.

    Example: (Eclipse)

    The View Last Run Results option is enabled only after you've run a test.

Back to top

Step 2: Configure LeanFT

  1. Open the Engine and Object Identification Settings from the LeanFT menu in your IDE, or from the system tray menu (right-click the LeanFT icon and select Settings).

  2. On the Engine tab, under Add-ins, configure LeanFT to use the Web Add-in only.

Save your changes to restart the LeanFT runtime engine with the Web Add-in.

Back to top

Step 3: Create a new testing project

Prerequisite for Visual Studio and NUnit:

Install the NUnit framework. For details about supported versions, see the LeanFT Product Availability Matrix.

  1. Create a new testing project using one of the LeanFT templates for your IDE.

    For example, in Eclipse, use the LeanFT > LeanFT Testing Project template.

    In IntelliJ IDEA, use the LeanFT Test > Testing project

    In Visual Studio, use one of the Visual C# > Test > LeanFT xx project templates.

    In Eclipse

    In Visual Studio

    In IntelliJ IDEA

    Give your project a meaningful name.

  2. Your project is created with a new class, using the standard format of the unit testing framework for the template you selected.

    This class contains a test method with the Test annotation (highlighted in the examples below), which you will use to include the test logic.

    Rename this test method with a more meaningful name.

    For example:

The following libraries are automatically referenced in the project:

  • The LeanFT library
  • The unit testing framework library (such as NUnit or JUnit)

Back to top

Step 4: Add code to open the Advantage Online Shopping site

In the blank test method, add code to launch the browser of your choice using LeanFT's SDK for your IDE.

Then add code to navigate to the Advantage Online Shopping URL: http://54.210.48.65:8080/

Tip: The examples below open Google Chrome. If you need to, update the code to launch a different browser.

Back to top

Step 5: Add code to click the User Account button

Add code to click the USER icon at the top right of the Advantage Online Shopping site.

Use LeanFT's OIC to obtain a unique identification for the USER object.

  1. Launch your browser.

    Note: If this is the first time you've launched your browser after installing LeanFT, you are prompted to enable the Functional Testing agent. Enable the agent to continue.

  2. Navigate to the Advantage Online Shopping demo application site: http://54.210.48.65:8080/.

  3. In your IDE, open theObject Identification Center (OIC) by selecting Object Identification Center from the LeanFT menu, or by clicking the Object Identification Center button in the IDE toolbar.

    Obtain a unique identification for the USER object:

    1. In the OIC, click Start spying:

      Then, hover over the USER object in the top-right corner of your browser window to highlight it. Click it to capture the object properties in the OIC.

      The following image shows a sample desktop with the browser window and OIC displayed, and the USER object highlighted.

    2. In the OIC, click the Recommended tab.

      Note that some properties are starred. LeanFT uses these stars to recommend a set of properties and values for uniquely identifying the spied object.

      There is only one object on the current page in our application that matches the starred properties and their current values. This is why these properties are recommended to identify our object.

    3. Click the Highlight button to see the USER object identified in your browser window.

    4. Click Generate Code to Clipboard , and paste the code into your test script.

      Click below to see what your identification code should look like. Your code may differ slightly as it is based on the properties recommended by the OIC for your environment.

      Tip: In addition to LeanFT's recommendations, you can customize the identification using the OIC's Edit mode. Click the Edit button to switch to Edit mode and select the properties you want to use to identify the object. Then, test the identification by clicking the Highlight button.

      For more details, see Experiment with test object properties.

  4. In your test, add code to click the USER object.

    Click to see how your test should look now:

Back to top

Step 6: Add code to start creating a new account

When the USER object is clicked, the login dialog box opens. Add code to click CREATE NEW ACCOUNT in this dialog box.

Use the same steps you performed earlier in Step 5: Add code to click the User Account button.

Click the following to see what your code should look like.

Back to top

Step 7: Add code to fill in the CREATE ACCOUNT form

Extend your test method code to fill in the user details in the CREATE ACCOUNT page that opens when the CREATE NEW ACCOUNT button is clicked in the previous step.

This time, use application models instead of including the object's identification code directly in the script.

Application Models enable you to model your application objects and then reference them from your scripts. The modeled objects can be reused in different scripts and by different users, which can be helpful when maintaining tests.

Do the following:

  1. Create a new application model.

    The Application Model Editor opens in your IDE, and you can use it to model the required objects, as described in the next step.

    For example, in Eclipse:

  2. Use the OIC to add the following objects to the application model:

    • User name, Email, Password, and Confirm password fields
    • I agree to the Advantage.com Conditions of Use and Privacy Notice option
    • REGISTER button

    From the Application Model editor, click the button to open the OIC in the Application Model editor.

    Tip: When opened from the Application Model editor, the OIC has an additional button () to add objects to your application model. You can close the other OIC instance.

    Do the following for each of the objects mentioned above:

    1. Spy the object in the application.

    2. At the bottom of the OIC, click the Add object button.

    If you are using Eclipse, save your application model.

    Click to view a sample application model:

  3. Close the OIC. Then use the test objects from the application model in your script to do the following:

    • Set the values in the edit fields.
    • Select the I agree ... option.
    • Click the REGISTER button.

    Click the following to see samples of what your script should look like:

    Note:  

    • ApplicationModel1 is the name you gave the application model when you created it (Eclipse/IntelliJ).

      It is also the class name defined for the application model in the right pane of the Application Model editor when the Application Model tab is selected (Visual Studio).

      LeanFT dynamically compiles your application model to a class of the same name, which, in turn, is used in your code.

    • The browser argument given to ApplicationModel1 in the first line of code is the one you created at the beginning of the script. This argument enables you to reuse the same application model with different browsers.

Click the following to display sample code of the entire test.

Back to top

Step 8: Run your test from the IDE

  1. (Optional) Customize your snapshots level test setting to save snapshots during the test run for each step performed and include them in the LeanFT run results.

    Test settings are defined in the test settings file referenced by your testing project:

    • Eclipse/IntelliJ: leanft.properties
    • Visual Studio: App.config

    For details, see Customize test settings.

  2. Build your project and run your test directly from your IDE.

Back to top

Step 9: View and analyze your run results

From your LeanFT IDE menu, select View Last Run Results.

If you customized your report settings as described in Step 8.1, notice the screenshots added to your report.

Your run report should look similar to the following:

C#

Java

Next steps: