Selecting an item from a Java drop-down list

You can modify the dynamic find() API to use the mapped and dynamic test objects, to select an item from a drop-down list in a Java application, as the following example illustrates:

This example uses the Classics Java application that is provided with HCL OneTest™ UI.

//Start the Classics JavaA application provided with HCL OneTest UI
        startApp("ClassicsJavaA");
        
        // Frame: ClassicsCD - Click the Place Order button (mapped test object)
        placeOrder().click();
        
    //Define root test objects
        RootTestObject  root = getRootTestObject();
        
        //Find the Java comboBox using properties exposed by the comboBox, define as array.
        TestObject[] to = root.
      find(atDescendant(".class","javax.swing.JComboBox","name", "nameCombo"));
     
        // Click the very first object that is found in the test object
        ((TextSelectGuiSubitemTestObject) to[0]).click();

        // Select one of the subitems from the drop-down list
        ((TextSelectGuiSubitemTestObject) to[0]).select("Bill Wu");
                
        // Frame: Member Logon  - Click the Cancel button 
        cancel().click();
        
        // Frame: ClassicsCD - Close the application
        classicsCD(ANY,MAY_EXIT).close();
       
Feedback