Confused about ID from JSX from React Native

Hi,

Sorry for a noob question but I have Googled this a lot and I’m still confused. I have a react native app that I want to write testing code for it to use on BrowserStack. From my understanding xpath is not a good idea because if any UI that gets updated within the app could make the testing useless (there may be more to it than that as well).

But I’m a bit confused as if I can just add an ID to my tags and be fine or is there something else that I should do?

From my understanding I shouldn’t use accessibility and if I use ID the test would work for both iOS and Android, is that correct?

Sorry I’m just really confused and would appreciate any guidance and help.

Best article I’ve found on React Native testing:

https://appiumpro.com/editions/76-testing-react-native-apps-with-appium

Thank you. I’ve been reading through that and adding test ID to anything that I need to be clicked. One thing that I am confused about is how do you enter values as when something is click a keyboard popsup. Is it via “sendkey” method?

Also does the inspector just help us find the element of the items? I’m a bit confused on why it’s needed if I’m writting the TestID for each element. Wouldn’t I be able to just say tap testID X, then scroll down, tap testID Y and so on?

again sorry for all of the questions I’m just confused and trying to still get a grasp of everything

Sure, sendkey works. Here is a basic tutorial on Appium. In this one they use setvalue:

https://appium.io/docs/en/about-appium/getting-started/index.html

Most users of Appium are not developers and generally do not have control over the app under test. They use the inspector for exploration, to help figure out what will work in such an app. Keeps it from being a black box. Many people don’t use it at all, or just use it sometimes. Kind of like a debugger.

thank you very much this is making a lot more sense now.

So last question, I promise lol. I’ve read all the browserstack documentation but I’m very confused about the execution of the test.

  1. Do i place the tests inside of my own source code?

  2. do I create a different file and once my app is uploaded I copy and paste that url into my scripts and execute the code from there?

2.1) if it is the 2nd option, how can I automate that so with every build that is uploaded it automatically runs those tests every time?

This forum is for questions, please ask as many as you need.

That said, I have spoken with BrowserStack folks but have not run tests on BrowserStack, so I don’t think I can give an authoritative answer. Here is the BrowserStack support page, I’m sure they would be happy to help.