[React Native] Toggle is not being clicked on android react native app

There are some toggles on the app which I want to click.
So the toggle element is being clicked by appium but in actual its no effect of that click as its not enabling the toggle.

` driver.pause(5000)
console.log(“*****”+driver.getContext()) – showing native app
const toggleSwitch= await element;
await toggleSwitch.waitForDisplayed({ timeout: 5000 });
const isToggleChecked = await closeMyAccount.toggle1.getAttribute(‘checked’);

if (isToggleChecked === 'false') {
    // Enable the toggle if it's currently off
    await  toggleSwitch.click();
    console.log('Toggle has been switched on');
} else {
    console.log('Toggle is already enabled');
}`

on the colnsole its printing “toggle has been switched on”. but its not working.

Log

 using: 'xpath',
[0-0]   value: '//android.widget.FrameLayout/android.view.ViewGroup[1]'
[0-0] }
[0-0] 2024-10-13T23:36:05.561Z INFO webdriver: RESULT {
[0-0]   'element-6066-11e4-a52e-4f735466cecf': '00000000-0000-00a8-ffff-ffff00000011',
[0-0]   ELEMENT: '00000000-0000-00a8-ffff-ffff00000011'
[0-0] }
[0-0] 2024-10-13T23:36:05.568Z INFO webdriver: COMMAND getElementAttribute("00000000-0000-00a8-ffff-ffff00000011", "checked")
[0-0] 2024-10-13T23:36:05.574Z INFO webdriver: [GET] http://127.0.0.1:4723/session/d7280a90-90e8-4179-b590-ac6edcd2de90/element/00000000-0000-00a8-ffff-ffff00000011/attribute/checked
[0-0] 2024-10-13T23:36:05.594Z INFO webdriver: RESULT false
[0-0] 2024-10-13T23:36:05.596Z INFO webdriver: COMMAND findElement("xpath", "//android.widget.FrameLayout/android.view.ViewGroup[1]")
[0-0] 2024-10-13T23:36:05.597Z INFO webdriver: [POST] http://127.0.0.1:4723/session/d7280a90-90e8-4179-b590-ac6edcd2de90/element
[0-0] 2024-10-13T23:36:05.597Z INFO webdriver: DATA {
[0-0]   using: 'xpath',
[0-0]   value: '//android.widget.FrameLayout/android.view.ViewGroup[1]'
[0-0] }
[0-0] 2024-10-13T23:36:05.644Z INFO webdriver: RESULT {
[0-0]   'element-6066-11e4-a52e-4f735466cecf': '00000000-0000-00a8-ffff-ffff00000011',
[0-0]   ELEMENT: '00000000-0000-00a8-ffff-ffff00000011'
[0-0] }
[0-0] 2024-10-13T23:36:05.648Z INFO webdriver: COMMAND elementClick("00000000-0000-00a8-ffff-ffff00000011")
[0-0] 2024-10-13T23:36:05.648Z INFO webdriver: [POST] http://127.0.0.1:4723/session/d7280a90-90e8-4179-b590-ac6edcd2de90/element/00000000-0000-00a8-ffff-ffff00000011/click
[0-0] 2024-10-13T23:36:05.695Z INFO webdriver: RESULT null
[0-0] Toggle has been switched on

and my app source is like below;
Uploading: image.png…

It can be easily wrong element NOT toggle one. Enable show touches in debug menu to see where tap happens.

herer is the source code and hierarchy of the element.

so there is a view group and within that textView

Selector suggested by Appium GUI may be easily point to several elements.
I you want help with selecting correct element:

  • ask developers to add IDs to elements
  • add show show touches in developer menu to check visually where tap happens on phone
  • you can share full page source to check your locator is correct

My app is developed in react.
Developer added the ID to the element but its not showing up when I am inspecting the element via appium inspector.

Good read on testing react native apps:

Ask developer to read above article and add accessibility label as well as testID. testID’s need to be available in the “UI Accessibility layer” or they cannot be accessed by Appium.

It is already covered by developer. Still not displayed in appium inspector.

Does it display in xCode inspector?

I am automating just android. not an iOS app

Ok with Android Studio inspector you can see it?