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

typeText enters wrong special characters #2

Closed
GoogleCodeExporter opened this issue Sep 17, 2015 · 3 comments
Closed

typeText enters wrong special characters #2

GoogleCodeExporter opened this issue Sep 17, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Write a test for an activity which has a text input field
2. call onView(withId(R.id.input_field)).perform(typeText("@{!_)")); in your 
text to populate the field

What is the expected output?
The field should be filled with the string: @{!_)

What do you see instead?
The field is filled with the text "`!=

What version of the product are you using? On what operating system?
Newly released espresso build with custom dependencies
espresso-1.0-SNAPSHOT.jar etc

Test device is Android 4.1.1 Galaxy Note 2 for the Japanese market.

Please provide any additional information below.

Keyboard layout differs from the default android keyboard

the relevant part of the test code:

public LoginTest() {
        super(Login.class);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();
        getActivity();
    }

    @Test
    public void testLogin() {
        onView(withId(R.id.edit_login)).perform(typeText("@{!_)"));
...
}

Original issue reported on code.google.com by maik.vl...@vuzz.com on 23 Oct 2013 at 7:16

Attachments:

@GoogleCodeExporter
Copy link
Author

I attached the output for the call

typeText("~!@#$%^&*()_+`=-[]{};:\";',.<>/?")

if that is of any help

Original comment by maik.vl...@vuzz.com on 23 Oct 2013 at 7:37

Attachments:

@GoogleCodeExporter
Copy link
Author

This seems to be an IME specific issue. This IME has a different interpretation 
of these special characters then what is expected (we get from 
http://developer.android.com/reference/android/view/KeyCharacterMap.html)

As a workaround, you can setText directly on the EditText by using your own 
ViewAction... something like this:

final class SetTextAction implements ViewAction {
  private final String text;

  SetTextAction(String text) {
   this.text = checkNotNull(text);
  }

  @SuppressWarnings("unchecked")
  @Override
  public Matcher<View> getConstraints() {
    return allOf(isDisplayed(), isAssignableFrom(EditText.class));
  }

  @Override
  public void perform(UiController uiController, View view) {
    ((EditText) view).setText(text);
  }

  @Override
  public String getDescription() {
    return "set text";
  }
}

We should probably add this to Espresso's ViewActions collection.

Original comment by vale...@google.com on 23 Oct 2013 at 7:07

  • Changed state: WontFix

@GoogleCodeExporter
Copy link
Author

Thanks for the fast reply. I incorporated the suggested code and it works. 
Thanks again

Original comment by maik.vl...@vuzz.com on 24 Oct 2013 at 1:11

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

No branches or pull requests

1 participant