stephenwang1011 / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

Solo.getText(String) takes regexp but does literal comparison #263

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. call Solo.getText("Hello (World)")  => this will throw an exception since 
the string is no valid regexp (since inside Getter.getView calls 
waiter.waitForText which expects a regexp)
2. however, in Getter.getView a few lines down robotium performs a literal 
comparison

    public <T extends TextView> T getView(Class<T> classToFilterBy, String text, boolean onlyVisible) {
=> REGEX        waiter.waitForText(text, 0, 10000, false, onlyVisible);
        ArrayList<T> views = viewFetcher.getCurrentViews(classToFilterBy);
        if(onlyVisible)
            views = RobotiumUtils.removeInvisibleViews(views);
        T viewToReturn = null;
        for(T view: views){
=> LITERAL      if(view.getText().toString().equals(text))
                viewToReturn = view;
        }

What is the expected output? What do you see instead?

I think that the Robotium API needs to make it very clear which api uses regex 
and which uses literal. Right now it seems to be a mixed bag. Ideally all text 
methods should be able to provide both versions of the api. Wherever a regex or 
matcher is passed in, then a regex comparison is made, whenever a String is 
passed in, a literal comparison is made.

What version of the product are you using? On what operating system?

robotium 3.2.1

Please provide any additional information below.

Original issue reported on code.google.com by rbur...@gmail.com on 23 May 2012 at 4:46

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. I agree, the best solution is to allow both inputs. 
Would it be possible for you to send a patch through github?

Original comment by renasr...@gmail.com on 23 May 2012 at 6:21

GoogleCodeExporter commented 9 years ago
I don't have a patch and I am not sure whether I will have the time to create 
one (as it probably would mean that approx half of the solo methods need to be 
rewritten. :(

Original comment by rbur...@gmail.com on 23 May 2012 at 12:03

GoogleCodeExporter commented 9 years ago
I will take care of it. Thanks again for reporting it.

Original comment by renasr...@gmail.com on 23 May 2012 at 12:13

GoogleCodeExporter commented 9 years ago
Just suffered from the same issue, can't click on a button with the string "+" 

Original comment by pmar...@gmail.com on 28 May 2012 at 8:13

GoogleCodeExporter commented 9 years ago
If you use "\\" before the text then special characters will not be taken into 
account.

Original comment by renasr...@gmail.com on 28 May 2012 at 8:15

GoogleCodeExporter commented 9 years ago
Thanks it works!

Original comment by Pablo.Ma...@fieldaware.com on 28 May 2012 at 8:42

GoogleCodeExporter commented 9 years ago
This has been partly fixed in Robotium 3.3. 

Original comment by renasr...@gmail.com on 11 Jun 2012 at 4:10