Why is it the button in my view cant be seen by UIAutomation?
Asked Answered
B

1

5

i am able to see the view but im unable to see/tap the button inside it. The button has a accessibility label of UIA_loginview_loginbutton with accesibility enabled. why is it not showing on logElementTree()?

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();
}

Log Element Tree: //Shows my view but not the button inside it

4) UIAElement [name:UIA_loginview_view value:(null) NSRect: {{0, 20}, {320, 460}}]

Breastplate answered 13/1, 2011 at 7:15 Comment(1)
could you please format your code using { } on top of the edit window - it helps a lot!Pokeweed
M
12

Ensure that the accessability property of the button is not hidden by its container views. Only those elements, which should be accessable by the user should be marked as such. If you set a container view enabled "Accessability" in Interface Builder all subelements in the hierarchie will not be visible by UIAutomation.

Did that help?

Movement answered 9/3, 2011 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.