Share this page

# Insight code sample (Java SDK)

In this topic:

## Identify and click a button using Insight

This example uses Insight to identify and activate an image object. It clicks button 2 on the calculator.

To run this test:

- The calculator application must be open
- A bitmap of button number 2 on the calculator must be stored in the directory in which the test is running

    import java.awt.image.RenderedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import com.hp.lft.sdk.insight.InsightDescription;
    import com.hp.lft.sdk.insight.InsightObject;
    import com.hp.lft.sdk.stdwin.*;
    .
    .
    .

    @Test
    public void testCalcWithInsight() throws GeneralLeanFtException, IOException {

    	WindowDescription calculatorDescription = new WindowDescription.Builder().windowClassRegExp("CalcFrame").windowTitleRegExp("Calculator").build();
    	// Identify the calculator application.
    	Window calculator = Desktop.describe(Window.class, calculatorDescription);

    	// Locate the bitmap.
    	File imgFile = new File("c:\\TwoButton.bmp");
    	RenderedImage image = ImageIO.read(imgFile);
    	InsightObject twoButton = calculator.describe(InsightObject.class, new InsightDescription(image));

    	// Click button number "2"
    	twoButton.click();

    }

Back to top

See also:

- UFT Developer Java SDK Reference
- UFT Developer Java SDK code samples

Tips to improve your search results... UFT Developer Java SDK Reference Version 15.0-15.0.2 UFT Developer SDK Reference All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: