Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6943619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:10:47+00:00 2026-05-27T13:10:47+00:00

So in my nib file i enabled accessibility and set the accessibility label of

  • 0

So in my nib file i enabled accessibility and set the accessibility label of a textfield to “txt”
I am trying to find this textfiled based on accessibility name and change its text.

var target = UIATarget.localTarget();
var application = target.frontMostApp(); 
var mainWindow = application.mainWindow();
mainWindow.logElementTree();

// This works
var textField = mainWindow.textFields()[0];

//this doesn't work
var textField = mainWindow.textFields()["txt"];

textField.setValue("Hello");

Am I doing anything wrong? How can I find a label based on accessibility label?

EDIT:

I am open to other solutions as well, I am trying to avoid getting the textfield based on the index

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:10:48+00:00Added an answer on May 27, 2026 at 1:10 pm

    I have a similar problem and setting the accessibility label value in the code instead in the nib file solve my problem. For example, I have a UITextField that I need to access in my UIAutomation script, I would have to set the accessibility label value in the viewDidLoad method as shown below.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        testTxtField.accessibilityLabel = @"myTxtBox";
    }
    

    and below is my UIAutomation Script

    var target = UIATarget.localTarget();
    var application = target.frontMostApp(); 
    var mainWindow = application.mainWindow();
    mainWindow.logElementTree();
    
    // This works
    //var textField = mainWindow.textFields()[0];
    
    // Now, this work too.
    var textField = mainWindow.textFields()["myTxtBox"];
    textField.setValue("Hello");
    
    UIALogger.logMessage("Text field:" + textField.label());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an NIB file with a button. When I click this button, the
I have a root view controller with no nib file, I tried adding this
I would like to set up a proxy object in the application NIB file.
I have a RootViewController & it's associated nib or xib file. This nib is
I am trying to load my next screen with (nib) file. whenever I am
I have a nib file I'm trying to instantiate in code. My UIViewController's main
I'm reading a custom table cell in tableView:cellForRowAtIndexPath: from a nib file. This works
I have a nib file. In this I created a new custom view (of
As in the one defined with Main nib file base name in the app's
Can I output the nib file name of an object from a - (void)awakeFromNib

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.