Share this page

# Oracle code samples (.NET SDK)

In this topic:

## Select an item from a ListOfValues

This example selects an item from a list of values attached to an edit field.

In the application, this list looks like a '...' button. To open the list from a test you need to use a SendKey(SoftKeys.ListOfValues) statement.

    using HP.LFT.SDK;
    using HP.LFT.SDK.Oracle;
    using NUnit.Framework;

    namespace HP.LeanFT.Examples.Oracle
    {
        [TestFixture]
        public class OracleCompleteExamples : UnitTestClassBase
        {

            [OneTimeSetUp]
            public void TestFixtureSetUp()
            {
    	   // Setup once per fixture
               // In this section, you launch the application you want to test.
               // Use the Web Add-in to navigate to the Oracle server in a browser,
               // log in to the application and navigate to the desired window.
               // Make sure to set up any configuration needed to open the application.
    	  }

    	  [SetUp]
    	  public void SetUp()
    	   {
                  // Before each test
    	   }

    	   //Select a value from a ListOfValues control.
    	   [Test]
    	   public void Test_ListOfValues()
    	   {
    	       //Create a description for a FormWindow control and set the properties to identify the FormWindow uniquely.
                   var distributionListsFormWindow = Desktop.Describe<IFormWindow>(new FormWindowDescription
    	        {
    		    ShortTitle = @"Distribution Lists"
    	        });

    	        //Create a description for an EditField control and set the properties to identify the EditField uniquely.
                   var applicationEditField = distributionListsFormWindow
    	        .Describe<IEditField>(new EditFieldDescription
    	        {
    		    Caption = @"Application",
    		    ObjectName = string.Empty
    	        });

    	       //Use the SendKey method with parameter SoftKeys.LIST_OF_VALUES to open the ListOfValues control.
    	       applicationEditField.SendKey(SoftKeys.ListOfValues);

    	       //Create a description for the ListOfValues control and set the properties to identify the ListOfValues uniquely.
                  var applicationsListOfValues = Desktop.Describe<IListOfValues>(new ListOfValuesDescription
    	       {
    		    Title = @"Applications"
    	       });

    	      //Use the Find method to find values inside the ListOfValues control.
    	       applicationsListOfValues.Find("A%");

    	       //Use the Select method to select an item from the ListOfValues control.
    	       applicationsListOfValues.Select(0);
               }

    	[TearDown]
    	publicvoid TearDown()
    	{
    		// Clean up after each test
    	}

    	[OneTimeTearDown]
    	publicvoid TestFixtureTearDown()
    	{
    		// Clean up once per fixture
    	}
        }
    }

Back to top

## Set the value of a cell in a table

This example sets and then checks the value of a cell in an Oracle table.

    using HP.LFT.SDK;
    using HP.LFT.SDK.Oracle;
    using NUnit.Framework;

    namespace HP.LeanFT.Examples.Oracle
    {
    	[TestFixture]
    	public class OracleCompleteExamples : UnitTestClassBase
    	{

    		[OneTimeSetUp]
    		public void TestFixtureSetUp()
    		{
    			// Setup once per fixture
    			// In this section, you launch the application you want to test.
    			// Use the Web Add-in to navigate to the Oracle server in a browser,
    			// log in to the application and navigate to the desired window.
    			// Make sure to set up any configuration needed to open the application.
    		}

    		[SetUp]
    		public void SetUp()
    		{
    			// Before each test
    		}

    		//Verify cells from a table.
    		[Test]
    		public void Test_Table()
    		{
    			//Create a description for a FormWindow control and set the properties to identify the FormWindow uniquely.
                           var oracleAlertOptionsFormWindow = Desktop.Describe<IFormWindow>(new FormWindowDescription
    			{
    				ShortTitle = @"Oracle Alert Options"
    			});

    			//Create a description for a List control.
    			//Set the correct properties in order to identify the List uniquely.
                           var functionList = Desktop.Describe<IFormWindow>(new FormWindowDescription
    			{
    				ShortTitle = @"Navigator"
    			})
    			.Describe<ITab>(new TabDescription
    			{
    				Label = @"Functions"
    			})
    			.Describe<IList>(new ListDescription
    			{
    				Caption = string.Empty,
    				ClassPath = @"oracle.forms.ui.VTList;oracle.ewt.lwAWT.LWList;oracle.ewt.lwAWT.LWDataSourceList;oracle.ewt.lwAWT.LWContainer;oracle.ewt.lwAWT.LWComponent;java.awt.Container;java.awt.Component;java.lang.Object;",
    				ObjectName = string.Empty
    			});

    			//Use the Activate method with the item name to open a new FormWindow.
    			functionList.Activate("+  System");
    			//Use the Activate method for child items.
    			functionList.Activate("Options");

    			//Create a description for a Table control and set the properties to identify the Table uniquely.
                            var table = oracleAlertOptionsFormWindow
    			.Describe<ITab>(new TabDescription
    			{
    				Label = @"Mail Systems"
    			})
    			.Describe<ITable>(new TableDescription
    			{
    				ObjectName = @"Table"
    			});

    			//Check whether the cell in row 0 and column 0 has a specific value.
                            //Use the Value property to get the value of the control.
    			Assert.AreEqual(table.Rows[0].Cells[0].Value.ToString(), "Oracle InterOffice");

    			//Get the cell from row 0 and column 1.
    			ITableCell cell = table.Rows[0].Cells[1];

    			//Use AsTestObject method to get the inside test object from a cell.
    			IEditField editField = cell.AsTestObject<IEditField>();

    			//After we get the test object we can use the SetText method to set the text of the EditField control.
    			editField.SetText("text");

    			//Check whether the previous step was performed correctly.
                            //Use the Value property to get the value of the control.
    			Assert.AreEqual(cell.Value.ToString(), "text");
    		}

    		[TearDown]
    		public void TearDown()
    		{
    			// Clean up after each test
    		}

    		[OneTimeTearDown]
    		public void TestFixtureTearDown()
    		{
    			// Clean up once per fixture
    		}
    	}

    }

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: