[英]Android Espresso: EditText with input type number
I want to test my android app with Espresso. 我想用Espresso测试我的android应用。 I have an editText
with android:inputType="number"
. 我有一个android:inputType="number"
的editText
。
If I write smth like that on my test: 如果我在测试中这样写:
onView(withId(R.id.editTextNumber)).perform(typeText("15"));
It doesn't work. 没用 But since typeText doesn't take an integer, how can I perform this test ? 但是由于typeText不需要整数,我如何执行此测试?
Thanks :) 谢谢 :)
Try this: 尝试这个:
onView(withId(blabla)).peform(typeText(String.valueOf("15"));
https://google.github.io/android-testing-support-library/docs/espresso/advanced/index.html https://google.github.io/android-testing-support-library/docs/espresso/advanced/index.html
if you can't find any way to enter numbers into your EditText, you'll have to avoid using typeText
and do it by injecting KeyEvents, and press numbers. 如果找不到在EditText中输入数字的任何方法,则必须避免使用typeText
并通过注入KeyEvents并按数字来实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.