繁体   English   中英

Android viewGroup 问题 - 使用 Appium 进行测试

[英]Android viewGroup issue - Testing with Appium

自动化测试非常新。
需要选择 SWITCH 选项。
努力为它编写代码(Android)。

在此处输入图像描述


由于此弹出窗口,测试失败。 需要选择“切换”选项。 以下是我的测试步骤。 测试在步骤“登录后导航到通知中心时”失败

在此处输入图像描述

在此处输入图像描述

我的 java 文件中该步骤的代码。
根据以下代码,如果元素 notificationIconAfterLogin 存在,则单击 notificationHeader。

这里 notificationIconAfterLogin 有xpath: (//android.widget.ImageView 1 ) 3
notificationHeader 有xpath: //*[@text='Notification Centre']

现在 notificationIconAfterLoginAndroidOptional 有xpath: (//android.view.ViewGroup 3 ) 1
switchDeviceBtn 有xpath: //*[@text='SWITCH']

@Given("^I navigate to Notification Center after login$")
    public void iNavigateToNotificationCenterAfterLogin() throws Exception {
        if (elementExists(notificationIconAfterLogin)) {
            loopClickUntilFound(notificationIconAfterLogin, notificationHeader);
        } else {
            loopClickUntilFound(notificationIconAfterLoginAndroidOptional, switchDeviceBtn);
        }
        waitFor(3);
        screenshot(); // Cap screen in notification center
    }

在此处输入图像描述

我的 SWITCH 选项没有被选中。 需要帮助来修复代码。
我在这里想念什么? 还有其他方法吗?

在 iNavigateToNotificationCenterAfterLogin() 方法中,首先检查是否显示 Switch 选项,然后单击 Switch 按钮,然后执行常规操作

示例 Apium-Java 代码:

if(driver.findElements(By.xpath("//*[@text='SWITCH']")).size()==1)
{
    driver.findElement(By.xpath("//*[@text='SWITCH']")).click()
}

暂无
暂无

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

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