是否可以通过以编程方式将输入输入模拟器来启动或修改浓缩咖啡测试记录?

时间:2019-05-22 16:32:52

标签: java android android-emulator android-espresso android-espresso-recorder

我正在尝试使用espresso测试基本的android登录应用程序(带有用户名,密码和登录按钮)。在espresso中,可以通过使用记录选项并与Emulator交互(输入用户名,密码并单击登录按钮)自动生成UI测试,并生成UI测试。 我的问题是,有什么方法可以通过编程方式将这些交互(输入用户名,密码和单击登录)发送到模拟器中,而无需手动与模拟器进行交互?

我尝试使用json数据填充用户名和密码,但是在记录测试期间,输入的这些数据不会作为操作记录在模拟器中。

 try {     
        JSONObject obj = new JSONObject(JSON_STRING);
        // fetch JSONObject named employee
        JSONObject employee = obj.getJSONObject("employee");
        // get employee name and salary
        name = employee.getString("name");
        password = employee.getString("password");
        // set employee name and salary in TextView's
        mEmailView.performClick();
        mEmailView.setText(name);
        mPasswordView.setText(password);
        mClick.performClick();

    } catch (JSONException e) {
        e.printStackTrace();
    }

0 个答案:

没有答案