【问题标题】:Android Slow Motion Automation TestingAndroid 慢动作自动化测试
【发布时间】:2017-04-21 12:08:07
【问题描述】:

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

@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());

【问题讨论】:

    标签: android testing junit automated-tests


    【解决方案1】:

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

    【讨论】:

    • 不,我需要以编程方式写入
    • 您是否尝试添加一些类似这样的行:“Thread.sleep(5000);”。我从未尝试过单元测试,但它适用于主应用程序。
    • 改为添加评论,这不符合回答的条件
    猜你喜欢
    • 2018-12-12
    • 2011-05-06
    • 2018-12-21
    • 2011-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-23
    相关资源
    最近更新 更多