Android慢动作自动化测试

标签 android testing junit automated-tests

您好,我已经编写了用于自动化测试的代码,它工作正常,但如果可能的话,我需要以慢动作的方式执行此自动化,请给我任何建议..我在下面提到了我的代码。此波纹管代码将成功运行,但我需要处理慢动作。

@RunWith(AndroidJUnit4.class)
public class SurveyAutomationTest {

    private String[] Name = new String[]{"prashant", "kiccha"};
    private String[] Phone = new String[] {"9742174495", "1234567890"};
    private String[] Distrcit = new String[]{"Koppal", "Bidar"};
    private String[] Taluk = new String[]{"koppal", "aurad"};
    private String[] Village = new String[]{"agalakera", "aknapur"};
    private String[] Etl1 = new String[]{"1-10","1-10"};
    private String[] Etl2 = new String[]{"20-50","20-50"};
    private String[] Etl3 = new String[]{"11-20","11-20"};
    private String[] Etl4 = new String[]{"20-50","20-50"};
    //private String[] District = new String[] {""};

    @Rule
    public ActivityTestRule<HomeActivity> mActivityRule = new ActivityTestRule<HomeActivity>(HomeActivity.class);

    @Test
    public void homeActivityTest() {

        for (int i = 0; i < 20; i++) {

            Random name = new Random();
            int Rname = name.nextInt(2);

            onView(withId(R.id.setting)).perform(click());

            onView(withId(R.id.connect_printer)).perform(click());

            onView(AllOf.allOf(withText("BTP110-0210\n98:D3:31:B2:82:C5"),isDisplayed())).perform(click());

            onView(withId(R.id.save)).perform(click());

            onView(AllOf.allOf(withId(android.R.id.button1), withText("OK"),isDisplayed())).perform(click());

            onView(withId(R.id.AddfarmerButton)).perform(click());

            onView(withId(R.id.farmernameedit)).perform(typeText(Name[Rname]), closeSoftKeyboard());

            onView(withId(R.id.farmerphnoedit)).perform(typeText(Phone[Rname]), closeSoftKeyboard());


            onView(withId(R.id.districtlist)).perform(click());

            ViewInteraction checkedTextView = onView(allOf(withId(android.R.id.text1), withText(Distrcit[Rname]), isDisplayed()));
            checkedTextView.perform(click());

            ViewInteraction spinner2 = onView(allOf(withId(R.id.taluklist), withParent(allOf(withId(R.id.Taluklayout), withParent(withId(R.id.linearLayout09))))));
            spinner2.perform(scrollTo(), click());

            ViewInteraction checkedTextView2 = onView(allOf(withId(android.R.id.text1), withText(Taluk[Rname]), isDisplayed()));
            checkedTextView2.perform(click());

            ViewInteraction spinner3 = onView(allOf(withId(R.id.villagelist), withParent(allOf(withId(R.id.Villagelayout), withParent(withId(R.id.linearLayout09))))));
            spinner3.perform(scrollTo(), click());

            ViewInteraction checkedTextView3 = onView(allOf(withId(android.R.id.text1), withText(Village[Rname]), isDisplayed()));
            checkedTextView3.perform(click());

            ViewInteraction imageButton3 = onView(allOf(withId(R.id.photo), withParent(allOf(withId(R.id.RelativeLayout16), withParent(withId(R.id.linearLayout3)))), isDisplayed()));
            imageButton3.perform(click());

            onView(withId(R.id.confirm)).perform(click());

最佳答案

您可以尝试在 Debug模式下逐步运行测试。

关于Android慢动作自动化测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43542333/

相关文章:

android - 如何不断地将GPS数据从android发送到服务器直到应用程序关闭

android - 我可以使用 RFCOMM 蓝牙协议(protocol)在 iOS 设备和其他设备之间共享数据吗?

ruby-on-rails-3 - 显示 Rails 测试失败的行号

spring-boot 单元测试获取应用属性

multithreading - 如何优化Grails构建和测试执行速度?

java - 使用 Mockito 的 argThat() 匹配器导致 "method ambiguous for the type"错误

使用 Maven 运行时会跳过 Spring 测试

android - 无法使用 ADT eclipse 在图形布局中打开 Android 布局 xml 文件

android - 如何避免嵌套权重?

java - 如何将命令行参数传递给 Junit 测试