Share this page

# Oracle code samples (Java 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.

    package com.hp.leanft.examples.oracle;

    import com.hp.lft.sdk.Desktop;
    import org.junit.AfterClass;
    import org.junit.BeforeClass;
    import org.junit.Test;
    import com.hp.lft.sdk.*;
    import com.hp.lft.sdk.oracle.*;
    import com.hp.lft.verifications.*;

    import unittesting.*;

    public class OracleExamples extends UnitTestClassBase {

    	@BeforeClass
    	public static void beforeClass() throws Exception {
    		globalSetup(OracleExamples.class);
    		// 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.
    	}

    	@AfterClass
    	public static void afterClass() throws Exception {
    		globalTearDown();
    	}

    	//Select a value inside ListOfValues control.
    	@Test
    	public void test_ListOfValues() throws GeneralLeanFtException {

    	    //Create a description for a FormWindow control and set the correct properties in order to identify the FormWindow uniquely.
    	    FormWindow distributionListsFormWindow = Desktop.describe(FormWindow.class, new FormWindowDescription.Builder()
    	    .shortTitle("Distribution Lists").build());

    	    //Create a description for an EditField control and set the properties to identify the EditField uniquely.
    	    EditField applicationEditField = distributionListsFormWindow
    	    .describe(EditField.class, new EditFieldDescription.Builder()
    	    .caption("Application")
    	    .objectName("").build());

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

    	    //Create a description for a ListOfValues control and set the properties to identify the ListOfValues uniquely.
    	    ListOfValues applicationsListOfValues = Desktop.describe(ListOfValues.class, new ListOfValuesDescription.Builder()
    	    .title("Applications").build());

    	    //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);
    	}
    }

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.

    package com.hp.leanft.examples.oracle;

    import com.hp.lft.sdk.Desktop;
    import org.junit.AfterClass;
    import org.junit.BeforeClass;
    import org.junit.Test;
    import com.hp.lft.sdk.*;
    import com.hp.lft.sdk.oracle.*;
    import com.hp.lft.verifications.*;

    import unittesting.*;

    public class OracleExamples extends UnitTestClassBase {

    	@BeforeClass
    	public static void beforeClass() throws Exception {
    		globalSetup(OracleExamples.class);
    		// 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.
    	}

    	@AfterClass
    	public static void afterClass() throws Exception {
    		globalTearDown();
    	}

    	//Verify cells from a table.
    	@Test
    	publicvoid test_Table() throws GeneralLeanFtException {

    	    //Create a description for a FormWindow control and set the properties to identify the FormWindow uniquely.
    	    FormWindow oracleAlertOptionsFormWindow = Desktop.describe(FormWindow.class, new FormWindowDescription.Builder()
    	    .shortTitle("Oracle Alert Options").build());

    	    //Create a description for a List control.
                //Set the correct properties in order to identify the List uniquely.
    	    List functionList = Desktop.describe(FormWindow.class, new FormWindowDescription.Builder()
    	    .shortTitle("Navigator").build())
    	    .describe(Tab.class, new TabDescription.Builder()
    	    .label("Functions").build())
    	    .describe(List.class, new ListDescription.Builder()
    	    .caption("")
    	    .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("").build());

    	    // 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.
    	    Table table = oracleAlertOptionsFormWindow
    	    .describe(Tab.class, new TabDescription.Builder()
    	    .label("Mail Systems").build())
    	    .describe(Table.class, new TableDescription.Builder()
    	    .objectName("Table").build());

    	    // Check whether the cell in row 0 and column 0 has a specific value.
                // Use the getValue method to get the value of the control.
    	    Verify.areEqual(table.getRows().get(0).getCells().get(0).getValue().toString(), "Oracle InterOffice");

    	    // Get the cell from row 0 and column 1.
    	    TableCell cell = table.getRows().get(0).getCells().get(1);

    	    // Use the asTestObject method to get the inside test object from a cell.
    	    EditField editField = cell.asTestObject(EditField.class);

    	    // 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 getValue method to get the value of the control.
    	    Verify.areEqual(cell.getValue().toString(), "text");
    	}
    }

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: