Add SDK test object steps to your tests

To run steps on your application, create steps containing LeanFT test objects, methods, and properties.

SDK test objects vs the Object Identification Center(OIC)/Application models

The Application Model editor and OIC enable you to generate test object description code automatically. Alternatively, you can write out your test object description code programmatically.

  • After creating a programmatic description for a LeanFT test object, create steps that will perform operations or retrieve values from your application objects. Use IntelliSense (for C# or Java) to select the relevant test object methods or properties.
  • You can check whether your application looks and acts as expected, using LeanFT Verification methods. For details, see Verifications.
  • If the test object methods and properties for an object do not provide the functionality you need, you can access the native properties and methods of an object. For details, see Access native objects, methods, and properties.
  • Make use of standard code and the capabilities provided by the testing framework you chose, together with LeanFT SDK code to create comprehensive tests that cover all aspects of your application.

Back to top

Code programmatic test object descriptions

  1. At the top of your test file, specify the SDK elements you plan to use by providing the required statements:

    Language File Statement
    C# .cs using
    Java .java import
    JavaScript .js var

    For example, if you want to create steps using the LeanFT core SDK as well as Web and Standard Windows technology objects, use the following:

  2. Determine the top-level parent object for your test, depending on the application type:

    Web-based applications

    The browser is the top-level parent test object. You use the BrowserFactory.Launch method to create to create a new instance of the Browser test object.

    Tip: You can alternatively use the BrowserFactory.Attach method to instruct LeanFT to run steps on an existing open browser. This also creates a Browser test object instance.

    Windows-based applications A window or dialog box is the top-level test object. You use the Desktop.Describe method to create a Window or Dialog test object.
    Mobile applications The device is the top-level test object. Use one of the MobileLab.LockDevice* methods to create an instance of the Device test object.
    SAP GUI for Windows applications

    The SAP GUI session is the top-level test object. You use the GuiSessionFactory.Launch method to create a new instance of the GuiSession test object.

    Tip: You can alternatively use the GuiSessionFactory.Attach method to instruct LeanFT to run steps on an existing open SAP GUI session. This also creates a GuiSession test object instance.

  3. Determine the test object hierarchy for the test object. Most objects will have a minimum of a two level hierarchy, but in some cases you may need to, or choose to, provide a deeper hierarchy.
    Possible hierarchies could be: browser> page > edit or window > button.

    You can use the OIC to view the recommended hierarchy for a specific object. For details, see Object Identification Center (OIC).

    Create each test object as a child of the relevant parent object.

  4. Determine the set of properties you want to use to describe your object.

    Tip: Use the OIC to find the available test object properties and current values for the object in your application.

    From the OIC, you can also copy the code for a test object description to the clipboard and paste it into your test.

    For details, see Object Identification Center (OIC)

  5. Create a new child object using the Describe method (C#/Java) /.$ (JavaScript) and the corresponding <TestObjType>Description object (C#/Java) that provides access to the relevant identification properties. Then provide property-value pairs that uniquely identify the object.

    The basic syntax is as follows:

    To specify a property value using a regular expression, use the following syntax:

    C#IDProp = As.RegExp(@"RegExpValue")
    Java.idProp(new RegExpProperty("RegExpValue")
    JavaScriptidProp:/RegExpValue/

Back to top

Regular expression guidelines

  • For C# and Java, specify regular expressions using VBScript regular expression syntax.  For example, to indicate any number of characters in a string, use .* and not just the * expression.

  • For JavaScript, use standard JavaScript syntax.  However, option flags are not supported and will be ignored.

  • By default, all regular expressions in descriptions are anchored to the beginning and end of the search string.

  • Regular expressions are not supported for Mobile test objects.

Back to top

Secure sensitive information

When a test must contain sensitive information, such as user names or passwords, to access the application being tested, you can use the LeanFT SDK to make this sensitive data harder to access.

  1. Use the Password Encoder tool to generate an encoded string resembling a mix of jumbled characters. This prevents the password from appearing in cleartext.

    Note: The Password Encoder tool does not use a global standard for encryption. It is not considered nor is it intended to be secure. Its only purpose is to ensure that passwords will not appear in cleartext while editing or running a test. The actual passwords and/or data are stored with your test's source code. If you are using real customer data or other sensitive information, you should take additional steps to ensure the security of that data.

    Run the Password Encoder tool as follows:

    Windows
    • From the LeanFT Start menu
    • In your IDE after installing the LeanFT plugin: LeanFT > Tools menu
    Mac/Linux

    In Terminal:

    1. Change to the <LeanFT installation>/Tools directory
    2. Run ./password-encoder <password-to-encode> [-me], where <password-to-encode> is the password you want to encode.

  2. When entering a password into a password field, use the generated string as the argument for a <TestObject>.SetSecure step (instead of the normal Set method). This hides the password, preventing it from being displayed in cleartext, but does not fully secure the password.

    For usage details, see the relevant SDK Reference.

Back to top

See also: