【发布时间】: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