Skip to content

Code/keyword improvement request: Get List Values #103

Description

@im2geek4you

The SwingLibrary keyword "Get List Values" currently only works if the list items are strings, however in some cases the list items are other objects (which in turn can have strings inside). The getListValues() method in ListOperator.java iterates all list items and tries to cast them to string like so:
items.add((String)model.getElementAt(i));
However this will fail when the list item is a complex object instead of a simple string. But since all objects in Java implement the toString() method, instead of doing a cast, if we call toString() method not only it will not fail, but will be more compatible with lists that have objects which contain strings and implement toString(). So my proposal is to change getListValues() to iterate items like so:
items.add(model.getElementAt(i).toString());
This shouldn't break anything and will increase compatibility with applications that use lists with objects. Application developers can use this opportunity to increase compatibility with Robot for automation on applications that use may customized GUI objects.

PS: since it is such a small change I don't think it deserves a pull request for this. Let me know if you think i'm wrong.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions