Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code/keyword improvement request: Get List Values #103

Closed
im2geek4you opened this issue Jan 31, 2018 · 1 comment
Closed

Code/keyword improvement request: Get List Values #103

im2geek4you opened this issue Jan 31, 2018 · 1 comment
Milestone

Comments

@im2geek4you
Copy link

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.

@badari412
Copy link
Contributor

badari412 commented Apr 4, 2018

@im2geek4you I think it all depends on how the developer implemented the list items. Suppose we have a list(Swing list) of "Vehicle" class objects. If I am not wrong, toString() will return something like this: Vehicle@1fee6fc and not some text unless the developer overrides the default "toString()" method.
For e.g.
public String toString(){ return name; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants