简体   繁体   中英

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.stack.imgur.com/M6tIk.jpg

so after spending 2 days, I'm able to go ahead from this step.

I just used this, unknowingly, and it worked for me.

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

Now, I just wanna know how it worked. Is this something that works whenever a pop up appears after a few milliseconds and controls keep waiting for the screen/overlay to come from where the elements might be located? Just wondering. Happy for now but I want to know exactly... Please guide how it worked. I am yet to understand this that upon adding below the line of code in desired capabilities, and by commenting above 2 lines of access, it managed to work smoothly and didn't show any error

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM