2013-10-31 16 views
1

這裏是UIAutomation的場景:UI自動化,如何在progressBar中動態引用.staticText?

我正在上傳文件'文件A'。在上傳期間,有一個反映上傳進度的進度條「0-100%」。此信息保存在.staticTexts & .value的 - 當我檢查logElementTree

UIATarget.localTarget().logElementTree(); 

一個。我需要參考&返回.static文本或此元素的值。 b。反對預期的'100%完成'。

我正在定義realProgress來捕獲靜態文本或進度條的值。 我試過不同的迭代... 捕獲當前文本百分比的正確方法是什麼?

var realProgress = window.staticTexts()[0]; 

輸出我的斷言功能:

Expected 'Upload Progress 100%' but was '[object UIAStaticText]'! 
target.frontMostApp().toolbar().buttons()["Icon Upload"].tap() 

由於

回答

2

的解決方案是在我的變量的末尾增加.name()即時斷言

 rProgress.name() 

if (rProgress.name() != "your message"){ 
UIALogger.logerror("your error message not equal to " + rProgress.name()) }