Git Product home page Git Product logo

Comments (3)

swabbass avatar swabbass commented on August 19, 2024

Hello! My team uses Appium for e2e tests, which does accessibility label lookups to find elements. On Android, this translates to looking up elements by their content description.

We've been unable to grab react-native-navigation tabs by their testID, because the content description contains other accessibility text:

private void setTabAccessibilityLabel(int itemIndex, int currentItem) {
AHBottomNavigationItem item = items.get(itemIndex);
String contentDescription = currentItem == itemIndex ? "selected, " : "";
if (item.getTitle(context) != null) contentDescription += (item.getTitle(context) + ", ");
if (AHHelper.isInteger(notifications.get(itemIndex).getReadableText())) {
int num = Integer.parseInt(notifications.get(itemIndex).getReadableText());
contentDescription += (num + " new item" + (num == 1 ? "" : "s") + ", ");
}
contentDescription += "tab, " + (itemIndex + 1) + " out of " + getItemsCount();
views.get(itemIndex).setContentDescription(contentDescription);
}

Would you accept a PR setting the content description of the tabs to their testID instead of what they are now?

Hey @talenfisher,

Today we are using tags for test ids, Appuim can use tags when using Espresso only, but, in order to use contentDescription you may consider apps that use contentDescription for its intended usage, and prevent clash with values of such attribute.

My suggestion is to plan a way to switch contentDescription based on the environment, test or production, which can be even generic for each view. wdyt?

from ahbottomnavigation.

talenfisher avatar talenfisher commented on August 19, 2024

My suggestion is to plan a way to switch contentDescription based on the environment, test or production

I like that - good call.

which can be even generic for each view. wdyt?

By this, do you mean relying on a property passed down through react-native-navigation to determine whether contentDescription or viewtag should be used for the testID? I'm not sure I'd want to do this for each individual tab. However, if it's just a single property that decides this for every tab in the bottom navigation, I think that is definitely preferable.

from ahbottomnavigation.

swabbass avatar swabbass commented on August 19, 2024

yup, on android for each view you can call setContentDescription and that simulates the accessibility id, but, I found it troublesome, see this old discussion, it might give you a basic idea of what issues you may face, especially using TextViews, EditTexts and other non-image views.

from ahbottomnavigation.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.