简体   繁体   English

无法在 Android 应用程序中找到自动警报弹出的 appium 中的元素

[英]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. [在此处输入图像描述][1]我有一个应用程序,它会根据用户是否要启用或不启用指纹选项来显示一个弹出窗口,让用户点击是或否。 -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我尝试通过它们的 id 和 xpaths 定位元素,但没有一个工作

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.所以花了 2 天后,我可以从这一步开始 go 。

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我还没有理解这一点,在所需功能的代码行下方添加后,并通过评论以上 2 行访问权限,它能够顺利工作并且没有显示任何错误

So Waqas here's your answer for understanding for the statement that you have used.因此,Waqas 这是您理解您所使用的陈述的答案。 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.在上面的代码中,驱动程序为每个元素等待 10 秒。 If element is not found it throws an exception called NoSuchElementException.如果未找到元素,则会引发名为 NoSuchElementException 的异常。

On the other hand we have explicit waits .另一方面,我们有明确的等待 That wait is based on some condition.这种等待是基于某些条件的。 It waits until the condition is not fulfilled.它一直等到条件不满足。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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