Closed
Description
It appears the Switch component in iOS has an accessibilityRole
prop of "button"
instead of "switch"
. This became apparent when testing with Appium.
import React from "react";
import { Switch } from "react-native";
function SwitchExample() {
return (
<Switch
testID="switch"
value={true}
/>
);
}
React Native version:
System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 118.87 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
Yarn: 1.19.1 - ~/.yarn/bin/yarn
npm: 6.10.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
Android SDK:
API Levels: 25, 26, 27, 28
Build Tools: 27.0.3, 28.0.3
System Images: android-27 | Intel x86 Atom_64, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.1 => 16.8.1
react-native: 0.61.2 => 0.61.2
Steps To Reproduce
- Run the example above.
- Notice the wrong type (
XCUIElementTypeButton
) in Appium Desktop - Override
accessibilityRole
with "switch". - Notice the type is now correct (
XCUIElementTypeSwitch
) in Appium Desktop.
Below is a screenshot of the expected result:
I did some investigation myself and it looks like this line and this line are the issue.