Automating windows apps in leanft in Java

To automate the standard windows apps, you will need to import below packages in LeanFT project. Here is the sample application that launches the notepad and enters text in it. Then it tries to close the notepad. After that it clicks on Don’t save button on the Dialog box.
 
com.hp.lft.sdk.stdwin


package leanft;

import com.hp.lft.sdk.Desktop;
import com.hp.lft.sdk.stdwin.*;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class NotepadTest extends BaseTest {

    @Test
    public  void test() throws Exception{

        new ProcessBuilder("C:\Windows\System32\notepad.exe").start();

        Thread.sleep(3000);

        Window notepadWin = Desktop.describe(Window.class,
                new WindowDescription.Builder().windowTitleRegExp("Notepad").build());

        Editor editor = notepadWin.describe(Editor.class,
                new EditorDescription.Builder().nativeClass("Edit").windowClassRegExp("Edit").build());

        editor.sendKeys("This is automated text");

        Thread.sleep(3000);
        notepadWin.close();

        Desktop.describe(Window.class, new WindowDescription.Builder()
                .ownedWindow(false).childWindow(false).windowClassRegExp("Notepad").windowTitleRegExp(" Notepad").build())
                .describe(Dialog.class, new DialogDescription.Builder()
                .ownedWindow(true).childWindow(false).text("Notepad").nativeClass("#32770").build())
                .describe(Button.class, new ButtonDescription.Builder()
                .text("Do&n't Save").nativeClass("Button").build()).click();
    }
}  

Complex problems, Simple Solutions