Share this page

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

    [TestMethod]
    public void TestWeb()
    {
      // Create the browser
      IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
      browser.Navigate("https://www.advantageonlineshopping.com/#/");
      browser.Sync();

      // Create the object property dictionary that will hold the OpenText Functional Testing property name and value, and initialize it
      IDictionary<string, object> objProp = new Dictionary<string, object>
      {
        { "acc_name", "TabletsCategory" }
      };

      // Describe the web element using the object property (It can also be used together with other properties.)
      var tabletsCategoryWebElement = browser.Describe<IWebElement>(new WebElementDescription
      {
        ObjectProperties = objProp
      });

      // Do operation on web Element
      tabletsCategoryWebElement.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

    [TestMethod]
    public void FTClick()
    {
      IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
      browser.Navigate("https://advantageonlinebanking.com/");
      browser.Sync();
      var registrationButton = browser.Describe<IButton>(new ButtonDescription
      {
        TagName = @"BUTTON",
        Name = @"Registration",
        ButtonType = @"button"
      });
      registrationButton.CallFTMethod("Click");
    }

Call a method that returns no value but requires arguments:

Copy code

    [TestMethod]
    public void FTClickPoint()
    {
      IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
      browser.Navigate("https://advantageonlinebanking.com/");
      browser.Sync();
      var registrationButton = browser.Describe<IButton>(new ButtonDescription
      {
        TagName = @"BUTTON",
        Name = @"Registration",
        ButtonType = @"button"
      });
      registrationButton.CallFTMethod("Click", 10,10,1);
    }

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

Copy code

    [TestMethod]
    public void FTExists()
    {
      IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
      browser.Navigate("https://advantageonlinebanking.com/");
      browser.Sync();
      var registrationButton = browser.Describe<IButton>(new ButtonDescription
      {
        TagName = @"BUTTON",
        Name = @"Registration",
        ButtonType = @"button"
      });
      bool result = registrationButton.CallFTMethod<bool>("Exist");
      Assert.IsTrue(result);
    }

Call a method that returns a value and requires arguments:

Copy code

    [TestMethod]
    public void FTExistsWTimeout()
    {
      IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
      browser.Navigate("https://advantageonlinebanking.com/");
      browser.Sync();
      var registrationButton = browser.Describe<IButton>(new ButtonDescription
      {
        TagName = @"BUTTON",
        Name = @"Registration",
        ButtonType = @"button"
      });
      bool result = registrationButton.CallFTMethod<bool>("Exist", 10);
      Assert.IsTrue(result);
    }

Back to top

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: