UIAutomator facebook login

2019-07-12 18:28发布

问题:

I created a UIAutomator login test for my app, and it works on some of the emulators. Problem is, it doesnt work on all of them.

    UiObject input = mDevice.findObject(new UiSelector().instance(0).className(EditText.class));
    input.setText(getFacebookLoginEmail());
    SystemClock.sleep(2000);

    UiObject input2 = mDevice.findObject(new UiSelector().instance(1).className(EditText.class));
    input2.setText(getFacebookLoginPassword());
    SystemClock.sleep(2000);

    UiObject buttonInput = mDevice.findObject(new UiSelector().instance(0).className(Button.class));
    buttonInput.click();
    SystemClock.sleep(2000);

Thats the code im currently using, most emulators run trough it just fine but on some, it doesnt type anything on the fields. I have a suspicion it might be caused by the emulator having different Facebook version, making the login page webview. For reference, on API 23 emulator it works, on API 22 one it doesnt.