【问题标题】:Android viewGroup issue - Testing with AppiumAndroid viewGroup 问题 - 使用 Appium 进行测试
【发布时间】:2020-12-02 20:51:45
【问题描述】:

对自动化测试非常陌生。
需要选择 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 选项没有被选中。 需要帮助来修复代码。
我在这里想念什么?还有其他方法吗?

【问题讨论】:

    标签: java android testing xpath appium


    【解决方案1】:

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

    示例 Apium-Java 代码:

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

    【讨论】:

      猜你喜欢
      • 2015-01-04
      • 1970-01-01
      • 1970-01-01
      • 2014-08-03
      • 2020-05-02
      • 2013-11-24
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      相关资源
      最近更新 更多