Share this page

# Extend test object methods and properties - code samples (JavaScript SDK)

In this topic:

## Use an OpenText Functional Testing property in a description

Use the acc_name property to identify a specific web element.

Copy code

    it("Use custom property on web", function(done) {

      // Create the browser
      Web.Browser.launch(Web.BrowserType.Chrome).then(function (browser) {
        browser.navigate("https://www.advantageonlineshopping.com/#/");

        // Create the object property map that will hold the OpenText Functional Testing property name and value and initialize it.
        var props = {"acc_name": "TabletsCategory"}

        // Describe the web element using the object property (It can also be used together with other properties.)
        var tabletsCategoryLink = browser.$(Web.Link({
           objectProperties: props
        }));

        // Do operation on web Element
        tabletsCategoryLink.highlight();
        browser.close();
      });
      whenDone(done);
    });

Back to top

## Call an OpenText Functional Testing test object method or propert

Call a method that returns no value and does not require arguments:

Copy code

    it("FTClick", function(done) {

      Web.Browser.launch(Web.BrowserType.Chrome).then(function (browser) {
        browser.navigate("https://advantageonlinebanking.com/");
        browser.sync();
        var registrationButton = browser.$(Web.Button({
          tagName: "BUTTON",
          name: "Registration",
          buttonType: "button"
        }));
        registrationButton.callFTMethod("Click");
        browser.close();
      });
      whenDone(done);
    });

Call a method that returns no value but requires arguments:

Copy code

    it("FTClickPoint", function(done) {

      Web.Browser.launch(Web.BrowserType.Chrome).then(function (browser) {
        browser.navigate("https://advantageonlinebanking.com/");
        browser.sync();
        var registrationButton = browser.$(Web.Button({
          tagName: "BUTTON",
          name: "Registration",
          buttonType: "button"
        }));
        registrationButton.callFTMethod("Click", 10, 10, 0);
        browser.close();
      });
      whenDone(done);
    });

Call a method that returns a value and does not require arguments:

Copy code

    it("FTExist", function(done) {

      Web.Browser.launch(Web.BrowserType.Chrome).then(function (browser) {
        browser.navigate("https://advantageonlinebanking.com/");
        browser.sync();
        var registrationButton = browser.$(Web.Button({
          tagName: "BUTTON",
          name: "Registration",
          buttonType: "button"
        }));

        registrationButton.callFTMethod("Exist").then((result) => {
          expect(result).toBe(true)
        });
        browser.close();
      });
      whenDone(done);
    });

Call a method that returns a value and requires arguments:

Copy code

    it("FTExistWTimeout", function(done) {

      Web.Browser.launch(Web.BrowserType.Chrome).then(function (browser) {
        browser.navigate("https://advantageonlinebanking.com/");
        browser.sync();
        var registrationButton = browser.$(Web.Button({
          tagName: "BUTTON",
          name: "Registration",
          buttonType: "button"
        }));
        registrationButton.callFTMethod("Exist", 20).then((result) => {
          expect(result).toBe(true)
        });
        browser.close();
      });
      whenDone(done);
    });

Back to top

See also:

- JavaScript SDK
- JavaScript SDK code samples

https://admhelp.microfocus.com Functional Testing for Developers 8942
Tips to improve your search results... OpenText™ Functional Testing for Developers Help Center OpenText™ Functional Testing for Developers Help 25.2 All View Local Help Center View Online Help Center Version: