Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何使用Espresso 2.2在Android中测试查看寻呼机滑动手势大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用Espresso 2.2为View pager编写自动化测试,我需要在其中测试滑动功能.

我写了下面的代码

@LargeTest
 public class FirstActivityTest {

 @Rule
 public ActivityTestRule<FirstActivity> firstActivityTestRule =
        new ActivityTestRule<>( FirstActivity.class);

@Test
public void testViewPagerSwipeFunctionality() throws InterruptedException{


   onView(withId(R.id.tv_commu)).check(matches(withText(R.String.first_screen_text)));

   onView(withId(R.id.tv_skip)).check(matches(withText(R.String.skip))) ;

   onView(withId(R.id.radio_button_first)).check(matches(ischecked()));
   onView(withId(R.id.view_pager)).perform(swipLeft());

   onView(withId(R.id.radio_button_second))
            .check(matches(ischecked()));
   onView(withId(R.id.tv_comp)).check(matches(withText(R.String.second_screen_text)));

   onView(withId(R.id.tv_skip)).check(matches(withText(R.String.skip))) ;

   onView(withId(R.id.view_pager)).perform(swipeLeft());

   onView(withId(R.id.radio_button_third))
            .check(matches(ischecked()));
   onView(withId(R.id.tv_skip)).check(matches(withText(R.String.skip))) ;
    onView(withId(R.id.tv_person)).check(matches(withText(R.String.third_screen_text)));}}

但是swipeLeft()方法没有得到解决.请告诉我我在哪里做错了?我们将非常感谢您的帮助.

解决方法

你必须导入swipeLeft(),如:
import static android.support.test.espresso.action.ViewActions.swipeLeft;

边注:示例代码具有swipLeft()而不是swipeLeft().

大佬总结

以上是大佬教程为你收集整理的如何使用Espresso 2.2在Android中测试查看寻呼机滑动手势全部内容,希望文章能够帮你解决如何使用Espresso 2.2在Android中测试查看寻呼机滑动手势所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。