Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android慢动作自动化测试_Android_Testing_Junit_Automated Tests - Fatal编程技术网

Android慢动作自动化测试

Android慢动作自动化测试,android,testing,junit,automated-tests,Android,Testing,Junit,Automated Tests,嗨,我已经为自动化测试写了代码,它工作得很好,但我需要以慢动作进行自动化,如果可能的话,请给我任何建议。。我在下面提到了我的密码。下面的代码将成功运行,但我需要慢动作 @RunWith(AndroidJUnit4.class) public class SurveyAutomationTest { private String[] Name = new String[]{"prashant", "kiccha"}; private String[] Phone = new St

嗨,我已经为自动化测试写了代码,它工作得很好,但我需要以慢动作进行自动化,如果可能的话,请给我任何建议。。我在下面提到了我的密码。下面的代码将成功运行,但我需要慢动作

@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());
@RunWith(AndroidJUnit4.class)
公共类调查自动测试{
私有字符串[]名称=新字符串[]{“prashant”,“kiccha”};
私有字符串[]电话=新字符串[]{“9742174495”,“1234567890”};
私有字符串[]District=新字符串[]{“Koppal”,“Bidar”};
私有字符串[]Taluk=新字符串[]{“koppal”,“aurad”};
私有字符串[]村庄=新字符串[]{“agalakera”、“aknapur”};
私有字符串[]Etl1=新字符串[]{“1-10”,“1-10”};
私有字符串[]Etl2=新字符串[]{“20-50”,“20-50”};
私有字符串[]Etl3=新字符串[]{“11-20”,“11-20”};
私有字符串[]Etl4=新字符串[]{“20-50”,“20-50”};
//私有字符串[]地区=新字符串[]{”“};
@统治
public ActivityTestRule mActivityRule=新的ActivityTestRule(HomeActivity.class);
@试验
公共无效homeActivityTest(){
对于(int i=0;i<20;i++){
随机名称=新随机();
int Rname=name.nextInt(2);
onView(带id(R.id.setting))。执行(单击());
打开视图(使用id(R.id.connect_打印机))。执行(单击());
onView(AllOf.AllOf(带文本(“BTP110-0210\n98:D3:31:B2:82:C5”),显示为())。执行(单击());
onView(带id(R.id.save)).perform(单击());
onView(AllOf.AllOf(带id(android.R.id.button1),带文本(“确定”),显示()).perform(单击());
onView(带id(R.id.AddfarmerButton)).perform(单击());
onView(带id(R.id.farmernamedit)).perform(键入文本(名称[Rname]),关闭软键盘();
onView(带id(R.id.farmerphnoedit)).perform(键入文本(电话[Rname]),关闭软键盘());
onView(withId(R.id.districtlist)).perform(click());
ViewInteraction checkedTextView=onView(allOf(withId(android.R.id.text1),withText(District[Rname]),isDisplayed());
选中TextView.perform(单击());
ViewInteraction spinner2=onView(allOf(带id(R.id.taluklist))、withParent(allOf(带id(R.id.Taluklayout))、withParent(带id(R.id.linearLayout09 ')));
喷丝头2.执行(滚动到(),单击());
ViewInteraction checkedTextView2=onView(allOf(withId(android.R.id.text1),withText(Taluk[Rname]),isDisplayed());
选中TextView2.perform(单击());
ViewInteraction spinner3=onView(allOf(带id(R.id.villagelist)),带父对象(allOf(带id(R.id.Villagelayout)),带父对象(带id(R.id.linearLayout09()()()));
喷丝头3.执行(滚动到(),单击());
ViewInteraction checkedTextView3=onView(allOf(withId(android.R.id.text1),withText(Village[Rname]),isDisplayed());
选中TextView3.perform(单击());
ViewInteraction imageButton3=onView(allOf(带id(R.id.photo))、withParent(allOf(带id(R.id.RelativeLayout16)、withParent(带id(R.id.linearLayout3))、isDisplayed());
imageButton3.执行(单击());
onView(带id(R.id.confirm)).perform(单击());

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

不,我需要以编程方式编写。如果您尝试添加以下行:“Thread.sleep(5000);”。我从未尝试过单元测试,但它可以在主应用程序上运行。请添加注释,这不符合回答条件