Search code examples
javaandroidautomationappium-android

Unable to locate elements in appium for auto alert pop up in Android App


[enter image description here][1]I have an App that shows a pop up to a user to either tap Yes or No depending upon if they want to enable or don't enable the Fingerprint option. -As the password gets authenticated, a pop up appears automatically to ask from the user if they want or don't want to enable FINGERPRINT.

I have tried locating the elements by their ids and xpaths but none is working

driver.findElement(By.id("etEmailAddress")).sendKeys("wa@qa.xyz");
driver.findElement(By.id("btn_continue")).click();
Thread.sleep(5000);
driver.findElement(By.id("etPassword")).sendKeys("PackageX@1");
         driver.findElementByXPath("//android.widget.EditText[@text='Password']").sendKeys("PackageX@1");
driver.findElement(By.id("btn_login")).click();
Thread.sleep(5000);

 ``` //driver.findElement(By.id("app.px.packagex:id/tvNo")).click();
        //driver.findElement(By.id("tvNo")).click();

the last 2 lines above:

    //driver.findElement(By.id("tvYes")).click();
    //driver.findElement(By.id("app.px.packagex:id/tvNo")).click();

I tried using id for both but not working

I want to tap on either of the buttons and then I will be taken into the App where I will be able to see a list of members in the App.

Below is the image in which that pop up appear as auto when CONTINUE button is tapped after providing the password, which asks for Yes or No for FINGERPRINT.:

[enter image description here][1]


  [1]: https://i.sstatic.net/M6tIk.jpg

Solution

  • So Waqas here's your answer for understanding for the statement that you have used. That is an implicit wait. So Implicit wait, wait for the element until it is found. If the element is found early than the given time, driver waits no more.

    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    

    In the above code driver waits for 10 seconds for every element to be. If element is not found it throws an exception called NoSuchElementException.

    On the other hand we have explicit waits. That wait is based on some condition. It waits until the condition is not fulfilled.