Share this page

# Extend test object methods and properties - code samples (Java 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

    @Test
    public void testWeb() throws GeneralLeanFtException {
      // Create the browser
      Browser browser = BrowserFactory.launch(BrowserType.CHROME);
      browser.navigate("https://www.advantageonlineshopping.com/#/");
      browser.sync();

      // Create the object property map that will store the OpenText Functional Testing property name and value
      Map<String, Object> objProp = new HashMap<>();

      // Initialize the map
      objProp.put("acc_name", "TabletsCategory");

      // Describe the web element using the object property (It can also be used together with other properties.)
      Link tabletsCategoryLink = browser.describe(Link.class, new LinkDescription.Builder()
           .objectProperties(objProp).build());

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

Back to top

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

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

Copy code

    @Test
    public void FTClick() throws GeneralLeanFtException {
      Browser browser = BrowserFactory.launch(BrowserType.CHROME);
      browser.navigate("https://advantageonlinebanking.com/");
      browser.sync();
      Button registrationButton = browser.describe(Button.class, new ButtonDescription.Builder()
        .tagName("BUTTON")
        .name("Registration")
        .buttonType("button").build());
      registrationButton.callFTMethod("Click");
    }

Call a method that returns no value but requires arguments:

Copy code

    @Test
    public void FTClickPoint() throws GeneralLeanFtException {
      Browser browser = BrowserFactory.launch(BrowserType.CHROME);
      browser.navigate("https://advantageonlinebanking.com/");
      browser.sync();
      Button registrationButton = browser.describe(Button.class, new ButtonDescription.Builder()
         .tagName("BUTTON")
         .name("Registration")
         .buttonType("button").build());
      registrationButton.callFTMethod("Click",10,10,0);
    }

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

Copy code

    @Test
    public void ETExists() throws GeneralLeanFtException {
      Browser browser = BrowserFactory.launch(BrowserType.CHROME);
      browser.navigate("https://advantageonlinebanking.com/");
      browser.sync();
      Button registrationButton = browser.describe(Button.class, new ButtonDescription.Builder()
        .tagName("BUTTON")
        .name("Registration")
        .buttonType("button").build());
      boolean result = registrationButton.callFTMethod("Exist", Boolean.class);
      Assert.assertTrue(result);
    }

Call a method that returns a value and requires arguments:

Copy code

    @Test
    public void FTExistsWTimeout() throws GeneralLeanFtException {
      Browser browser = BrowserFactory.launch(BrowserType.CHROME);
      browser.navigate("https://advantageonlinebanking.com/");
      browser.sync();
      Button registrationButton = browser.describe(Button.class, new ButtonDescription.Builder()
        .tagName("BUTTON")
        .name("Registration")
        .buttonType("button").build());
      boolean result = registrationButton.callFTMethod("Exist", Boolean.class, 20);
      Assert.assertTrue(result);
    }

Back to top

See also:

- Java SDK
- Java 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: