2012-11-02 19 views
3

對於該線的測試代碼:view.scrollViews()[0] .tapWithOptions({tapOffset:{X:0.32,Y:0.25}})scrollToVisible錯誤而測試器件上,UIAutomation

我收到此錯誤

2012-11-02 18:09:23 +0000 None: Script threw an uncaught JavaScript error: target.frontMostApp().mainWindow().scrollViews()[0] could not be tapped on line 244 of feature.js 
2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scrollViews()[0].tapWithOptions({tapOffset:{x:"0.32", y:"0.25"}}) 
2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scrollViews()[0].scrollToVisible() 
2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scrollViews()[0] - scrollToVisible cannot be used on the element because it does not have a scrollable ancestor. 
2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scrollViews()[0] - scrollToVisible cannot be used on the element because it does not have a scrollable ancestor. 
2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scrollViews()[0] could not be tapped 

的logelement樹是這個樣子

UIATarget "MyiPadname" {{0, 0}, {1024, 768}} 
elements: { 
UIAApplication "myAppName" {{0, 0}, {1024, 768}} 
elements: { 
    UIAWindow "(null)" {{0, 0}, {1024, 768}} 
    elements: { 
     UIAScrollView "(null)" {{0, 0}, {1024, 768}} 
     elements: { 
      UIAImage "(null)" {{1017, 761}, {7, 7}} 
      UIAImage "(null)" {{1017, 761}, {7, 7}} 
     } 
     UIAImage "nav_bar.png" {{0, 724}, {1024, 44}} 
     UIAButton "button featured" {{0, 730}, {134, 39}} 
     UIAButton "See the world" {{134, 730}, {223, 39}} 
     UIAButton "button my favorites" {{357, 730}, {180, 39}} 
     UIAButton "button settings" {{967, 736}, {33, 27}} 
    } 
} 
} 

我使用的XCode 4.5.1。任何人都可以幫助我解決這個問題。謝謝

+0

有AF ***錯誤的手段,這是打開我瘋了 – Bgi

+0

對不起,我沒看到你想點擊一個滾動型,這是奇怪的 – Bgi

回答

1

你有沒有使用iOS 5.x模擬器或iOS 5.x設備?如果是的話,我看到了同樣的問題。我相信Xcode 4.5.1不喜歡ScrollViews。

但是,我找到了解決方法。

我的元素看起來像:

target.frontMostApp().mainWindow().scrollViews()[0].buttons()["Wikipedia"] 

因此,而不是直接訪問按鈕,我試圖訪問一個靜態文本的按鈕。

target.frontMostApp().mainWindow().scrollViews()[0].buttons()["Wikipedia"].staticTexts()["Wikipedia"].tap(); 

我希望這對你有效。

+0

這僅因爲你一個UIStaticText在按鈕內。我贊成,因爲解決方法的一般想法是正確的:這個問題似乎只發生在按鈕上 – Bgi

1

在滾動視圖上執行flickInsideWithOptions時出現同樣的錯誤。我相信自動化框架試圖滾動到您想要先點擊的元素,但如果由於某種原因禁用滾動,它會因您提到的錯誤而失敗。

只有一個辦法如何解決它 - 自動化框架不知道,我們正在利用滾動視圖 - 我們必須避免的抽頭/滑動/輕彈功能的特殊版本。例如,我們將點擊mainWindow

var buttonRect = button.rect(); 
var windowRect = mainWindow.rect(); 

var xPos = (20 + buttonRect.origin.x)/windowRect.size.width; 
var yPos = (50 + buttonRect.origin.y)/windowRect.size.height; 

mainWindow.tapWithOptions({tapOffset:{x:xPos, y:yPos}});