Open topic with navigation

# Launch AUT code samples (Java SDK)

The following code samples show how to launch a desktop application using different parameter combinations. To used this capability, you must create an application whitelist file. For details, see Run desktop applications from the LeanFT SDK.

Launch the calc application using its full path and then close the application.

    @Test
    public void testAutFullPath() throws GeneralLeanFtException {
    	Aut calc = Desktop.launchAut("C:\\Windows\\System32\\calc.exe");
    	//your test code goes here
    	calc.close();
    }

Launch the calc application using only its name.

    @Test
    public void testAutShortcut() throws GeneralLeanFtException {
    	Aut calc = Desktop.launchAut("calc");
    	//your test code goes here
    	calc.close();
    }

Launch notepad using its name and the file that you want to open.

    @Test
    public void testAutWithArgument() throws GeneralLeanFtException {
    	Aut notepad = Desktop.launchAut("notepad", "C:\\Temp\\1.txt");
    	//your test code goes here
    	notepad.close();
    }

Launch notepad using two arguments: the file that you want to open and a notepad argument for opening the file in unicode, and the directory where the file resides.

    @Test
    public void testAutWithArgumentsAndWorkingDirectory() throws GeneralLeanFtException {
    	Aut notepad = Desktop.launchAut("notepad", new String[] {"/w", "unicode.txt"}, "C:\\Temp");
    	//your test code goes here
    	notepad.close();
    }

Describe the environment you need and launch the calc application on a grid node using its name.

    @Test
    public void testAutShortcutOnGrid() throws GeneralLeanFtException {
           //aquire an environment
           EnvironmentDescription envDesc = new EnvironmentDescription.Builder().build();
           envDesc.set("ostype", "Windows")
           DesktopEnvironment env = EnvironmentFactory.get(envDesc);

           Aut calc = env.launchAut("calc");
    	//your test code goes here
    	calc.close();
    }