vendredi 12 avril 2019

Wait for and click buttons for install and open in Playstore

I want to install and open an app via the playstore automatically. This is the code:

 // Search for Install Button in Google Play Store and click it
    SearchCondition<UiObject2> isAvailableInstall = Until.findObject(By.textContains(install));
    device.wait(isAvailableInstall, 100000);
    UiObject installButton = device.findObject(new UiSelector()

            .textContains(install));

    if (installButton.exists()) {
        installButton.click();

    }

    // Open App after install

    //TODO: FIX
    device.wait(Until.findObject(By.textContains(open)), 100000);
    UiObject openButton = device.findObject(new UiSelector()

            .textContains(open));

    if (openButton.exists()) {
        openButton.click();

    }

"install" And "open" are Strings with the language specific names of the buttons (in english INSTALL and OPEN) Sometimes, he does not find the open button in the device.wait and timeouts. Why?

Aucun commentaire:

Enregistrer un commentaire