入门Robotium。 EditText上没有发现 [英] Getting started with Robotium. EditText not found
本文介绍了入门Robotium。 EditText上没有发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚开始接触Robotium,写我的第一次测试,我得到这个奇怪的错误:
I just getting started with Robotium, writing my first test and I'm getting this weird error:
junit.framework.AssertionFailedError: 2131165500 EditTexts are not found!
这是我的我的测试用例
public class TestRegistrationActivity extends ActivityInstrumentationTestCase2<RegistrationActivity>{
private Solo solo;
public TestRegistrationActivity() {
super(RegistrationActivity.class);
}
public void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
@Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
}
@UiThreadTest
public void testSomeStuff(){
for (View v : solo.getCurrentViews()) {
Log.d(v.getClass().getSimpleName()+": "+v.getId());
}
solo.getEditText(R.id.txtCountryCode);
}
}
这是日志:
03-13 17:06:18.318: D/DEBUG(7907): EditText: 2131165500
03-13 17:06:18.322: D/DEBUG(7907): PhoneEditText: 2131165501
正如你所看到的:
As you can see:
- 的
solo.getCurrentViews()
确实认识到,ID为视图2131165500
存在。 - 的
solo.getEditText(R.id.txtCountry code)
行总是失败。
- The
solo.getCurrentViews()
does indeed recognize that the view with id2131165500
exists. - The
solo.getEditText(R.id.txtCountryCode)
line always fails.
有什么地方出错了?
推荐答案
固定。
问题是,我认为 solo.getEditText(INT)
拍了查看
id作为参数。相反,它把视图的索引。
The problem was that I thought solo.getEditText(int)
took a View
id as parameter. Instead it took the view's index.
这篇关于入门Robotium。 EditText上没有发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文