Search code examples
javascriptiosios-ui-automationuiaccessibility

Accessing label text using accessibility identifiers


I have added an accessibility identifier to a label so that I can use it in my UIAutomation javascript files. How do I access the text on the label using accessibility identifier?

Suppose "aLabel" is the accessibility identifier and my javascript function to access the text on that label is:

appLabelValue:function()
{
return this.getElement('aLabel').value();
}

I even tried replacing .value() with .text() in the above method but I am getting same error for both i.e. undefined is not a function.

Please suggest.


Solution

  • You access the values of UIElements by using name() try this

    appLabelValue:function()
    {
    return this.getElement('aLabel').name();
    }