Automating WPF apps in leanft in Java

Below example illustrates how to automate WPF application using LeanFT. Note that we need to import classes from below package.
 
com.hp.lft.sdk.wpf

In below example, we are first identifying the WPF window with title – Bus Application. After that we have identified the ComboBox with name sourceCity and finally we have listed down all the options in sourceCity ComboBox.
 
package leanft;

import com.hp.lft.sdk.Desktop;
import com.hp.lft.sdk.wpf.ComboBox;
import com.hp.lft.sdk.wpf.ComboBoxDescription;
import com.hp.lft.sdk.wpf.Window;
import com.hp.lft.sdk.wpf.WindowDescription;
import org.junit.Test;

/**
 * Created by Sagar on 20-07-2016.
 */
public class WpfTest extends BaseTest {

    @Test
    public void test1() throws Exception{
       Window win = Desktop.describe(Window.class, new WindowDescription.Builder()
                .objectName("Bus Application").fullType("window").windowTitleRegExp("Bus Application").build());

       ComboBox box= win.describe(ComboBox.class, new ComboBoxDescription.Builder()
                .objectName("sourceCity").build());

        for (String s :box.getItems()     ) {
            System.out.println(s);
        }

    }
}

Complex problems, Simple Solutions