简体   繁体   English

在本机应用程序中使用Appium处理弹出窗口

[英]Handling popups with Appium in a native app

I am using Appium to automate a native iOS and Android app using Java. 我正在使用Appium使用Java自动执行本机iOS和Android应用程序。 The app features a Login/Logout proccess, which I execute in the start/end of every test case, and while logged in the app, apart from all the actions that I can do there, there are many random pop-ups for "Rate us" system, enabling Notifications, Locations usage and many more. 该应用程序具有“登录/注销”过程,我在每个测试用例的开始/结束时都执行该过程,并且在登录该应用程序时,除了可以在其中执行的所有操作外,还有许多用于“费率”的随机弹出窗口我们”系统,从而启用“通知”,“位置使用情况”等等。 The problem is that some of those pop-ups are coded to appear in different intervals even at random times, so what I am doing now is waiting to dismiss them in the start of each and every case after Login (This takes a lot of time for all the pop-ups to appear). 问题是,其中一些弹出窗口被编码为即使在随机时间也以不同的间隔出现,所以我现在要做的是等待登录后在每种情况下都将其关闭(这需要很多时间让所有弹出式窗口都显示)。

Is there a way to wait throughout the whole case for the popup(s) to appear and then be dismissed, while executing the other steps, or is the only workaround to dismiss all the popups before executing the rest of the case? 是否有办法在整个案例中等待弹出窗口出现,然后在执行其他步骤时将其关闭,还是在执行其余案例之前消除所有弹出窗口的唯一解决方法?

We've had similar problems and the best solution we have found so far is to implement the pop-ups and the tests so that the behavior of the app is always consistent in testing situation. 我们也遇到过类似的问题,到目前为止,我们发现的最佳解决方案是实施弹出窗口和测试,以使应用程序的行为在测试情况下始终保持一致。 However, even though there is no actual built in support for this, we have used variation of the following successfully. 但是,即使对此没有实际的内置支持,我们也成功地使用了以下内容的变体。 This is in python/pseudocode, but I don't think it should be much different in Java. 这是在python / pseudocode中,但我认为Java中应该没有太大不同。

In this you handle the element you wish, unless it is not found, in which case we assume there are pop-ups over it. 在这种情况下,您可以处理所需的元素,除非找不到该元素,否则在这种情况下,我们会假设它上方有弹出窗口。 We handle the pop-ups first and finally should find the element we need. 我们首先处理弹出窗口,最后应该找到所需的元素。

def handle_element_x(self, timeout):
    """handles element x unless there are popups overlapping it.
    """
    while elapsed_time < timeout:
        if appium._is_element_present(element_x_locator):
            // handle element x and return
            return True
        if appium._is_element_present(popup1_locator):
            // handle popup1
            continue
        if appium._is_element_present(popup2_locator):
            // handle popup2
            continue
        ...
        time.sleep(1) 

Naturally you need to implement this with all the elements that can be overlapped with some pop-up. 自然,您需要使用可以与某些弹出窗口重叠的所有元素来实现此功能。

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

相关问题 ruby + appium或java + appium用于移动原生应用程序自动化 - ruby+ appium or java+appium for mobile native app automaion 使用 Appium 在 Android 本机应用程序中滚动的问题 - Issue with Scrolling in Android Native app using Appium Appium IOS Native应用程序按标签查找元素 - Appium IOS Native app find element by label 使用Appium处理android应用中的弹出窗口 - Handling pop-up in android app using Appium 如何处理适用于OS Marshmallow及更高版本的Appium android测试中的App权限弹出窗口(系统弹出窗口,例如设备位置/联系人列表)? - How to handle App permission pop ups (system popups like device location/contact list) in Appium android tests for OS Marshmallow and above? 如何使用appium和browsermob代理为本地应用捕获网络 - how to capture network for native app with appium and browsermob proxy 无法使用appium 1.6.4在android native应用中单击按钮 - Not able to click on button in android native app using appium 1.6.4 如何使用 appium 在具有 recyclerview 的 android 本机应用程序中滚动屏幕 - How to scroll screen in android native app having recyclerview using appium 无法使用Java Client 7.0滚动使用Appium的Android Native App - Unable to scroll android native app with appium using java client 7.0 Appium Android 使用 Serenity BDD 切换应用程序(本机和 chrome) - Appium Android switch app (native and chrome) using serenity BDD
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM