[英]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.