2011-01-13 80 views
5

我能夠看到視圖,但即時無法看到/點擊其中的按鈕。該按鈕具有啓用了輔助功能的UIA_loginview_loginbutton的輔助功能標籤。爲什麼它不顯示在logElementTree()?爲什麼我的視圖中的按鈕不能被UIAutomation看到?

var target = UIATarget.localTarget(); 
var application = target.frontMostApp(); 
var window = application.mainWindow(); 
var view = window.elements().firstWithName("UIA_loginview_view"); 


UIATarget.localTarget().logElementTree(); 
UIATarget.localTarget().frontMostApp().logElementTree(); 


if(view == null || view.toString() == "[object UIAElementNil]") 
{ 
UIALogger.logFail("View not found - "+view.toString()); 
} 
else 
{ 
    UIALogger.logPass("View found - "+view.toString()); 
    UIALogger.logMessage("View Elements length - "+view.buttons().length); 
    view.buttons()["UIA_loginview_loginbutton"].tap(); 
} 

登錄元素樹://顯示我的視圖,但不是按鈕,它

4)UIAElement [名稱內:UIA_loginview_view值:(空)的NSRect:{{0,20},{320, 460}}]

+0

請您使用{}在編輯窗口的頂部格式化你的代碼 - 它有很大幫助! – Axel 2011-01-13 07:24:54

回答

12

確保該按鈕的可訪問性屬性未被其容器視圖隱藏。只有那些用戶可以訪問的元素應該被標記爲這樣。如果在界面構建器中將容器視圖設置爲啓用「Accessability」,則UIAutomation將不會顯示hierarchie中的所有子元素。

這有幫助嗎?

+0

是的,它確實謝謝你! :D – Aldrich 2011-03-10 07:37:31

相關問題