Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot recognize modal by appium

I have an application created by react-native which contains a modal raise from bottom. Now I'm tring to use appium to automate the application and in android it works fine. While in iOS, when I try to use appium inspector on the modal, it just get penetrated and return control below.

        <Modal style={styles.bottomModal} isVisible={btmModal} backdropOpacity={0.3} onBackdropPress={this._closeBtmModal}>
          <View style={styles.ways}>
            <TouchableOpacity accessibilityLabel={IDS.MANUAL_NAV_CAMERA} testID={IDS.MANUAL_NAV_CAMERA} style={styles.line} onPress={() => this._navCamera()}>
              <Image style={styles.scan} source={require('../../../resources/images/scan.png')} /><Text style={styles.lineTxt}>扫码绑定</Text>
            </TouchableOpacity>
            <TouchableOpacity accessible={true} accessibilityLabel={IDS.MANUAL_ADD_TEXT} testid={IDS.MANUAL_ADD_TEXT} style={styles.line} onPress={this._navManualBindMfa}>
              <Text style={styles.lineTxt}>手动输入</Text>
            </TouchableOpacity>
            <TouchableOpacity accessible={true} accessibilityLabel={IDS.MANUAL_ADD_MODAL_CANCEL} testId={IDS.MANUAL_ADD_MODAL_CANCEL} style={[styles.line, styles.cancelline]} onPress={this._closeBtmModal}>
              <Text style={styles.cancelTxt}>取消</Text>
            </TouchableOpacity>
          </View>
        </Modal>

Try to get appium inspector working against this modal. Thanks for any suggestion in advance.

like image 814
EvanChen Avatar asked Aug 01 '26 23:08

EvanChen


2 Answers

Possible strategies to try:

  1. "setting accessible={false} on outer most layer makes child views accessible."

See https://github.com/appium/appium/issues/6517#issuecomment-298037046

  1. If your modal has a transparent background the components behind may will still be marked as visible. I use an environment variable set in the build for testing with appium which removes the transparency option. This does mean that the build being tested is not identical to the normal build
like image 134
Martin Lockett Avatar answered Aug 04 '26 08:08

Martin Lockett


  • React-Native 0.63
  • Desktop Appium 1.22.0
  • Appium Inspector 2022.1.2

In our project the obstacle was the element Pressable. Setting property accessible={false} to it fixed an ability for Appium to find elements on modal windows as well. <TouchableOpacity accessible={false}> also plays role for finding elements on screens.

I have to highlight that Appium Inspector's screenshot view still won't recognize elements, but its searching functionality ('id' for iOS) finds them.

like image 25
Algo Avatar answered Aug 04 '26 08:08

Algo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!