Idea ID: 2874661

UFT Developer using attachedText method to automate Swing applications.

Status : New Idea
The main issue here is that attachedText method (which expects a String Class UiObjectBaseDescription.Init<T extends UiObjectBaseDescription.Init<T>> (microfocus.com) ) does not find the Window object which has the text ‘Select the type of licence you want’.
Instead what we’ve had to do as a workaround is  filter through the children of the Window object , find the child object that has the text we want (e.g. by using the getAttachedText() method Class UiObjectBaseDescription (microfocus.com) ) and then select based on the index.  
We’d have expected this to be automatically done via the attachedText method initially used. I suspect this will be an issue for others using UFT Developer who are also trying to automate Swing applications.
 
The code below fails to find the list based on the attached-text property.  In the work around we manually perform the same actions and can find the item by attached-text. Please let us know if you require any further information, thanks.

Expectation

var window = workstation.getActiveWindow();

var list = window.describe(List.class, new ListDescription.Builder()

    .nativeClass("com.nuix.swing.list.FormattedList")

    .attachedText("Select the type of licence you want:")

    .build());

Workaround

@Given("I select the {string} item from the {string} list")

public void iSelectTheOptionFromTheDropdown(String itemName, String listName) throws GeneralLeanFtException, CloneNotSupportedException

{

    var window = workstation.getActiveWindow();

    var lists = window.findChildren(List.class, new ListDescription.Builder()

        .nativeClass("com.nuix.swing.list.FormattedList")

        .build());

    var list = Arrays.stream(lists).filter(entry -> {

        try

        {

            return entry.getAttachedText().startsWith(listName);

        }

        catch (GeneralLeanFtException ex)

        {

            throw new RuntimeException(ex);

        }

    }).findFirst();

    assertThat(list.isPresent(), is(true));

    var item = list.get().getItems().stream().filter(entry -> {

        try

        {

            return entry.getText().startsWith(itemName);

        }

        catch (GeneralLeanFtException ex)

        {

            throw new RuntimeException(ex);

        }

    }).findFirst();

    assertThat(item.isPresent(), is(true));

    list.get().select(item.get().getIndex());

}

 

Regards

Ampion Product Support 

 

Tags:

Labels:

Execution
Integrations
Technologies