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:

- 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: