react-native-picker没有accessibilityId和testId

时间:2019-05-02 13:59:22

标签: react-native modal-dialog picker

我正在使用react-native-picker,我可以看到所有代码都是用本地语言编写的(Android为Java,iOS为Objective C)。

对于自动化测试,我们需要此控件具有不可用的accessibilityLabel和testId道具。实际上,重点放在其背后的控件上。我使用了本机选择器。

我们非常感谢您的帮助。

下面是我的本机代码

renderBillingStatePicker() {
    var stateVal = [];
    billingStateCodes = stateData.values;
    stateVal = this.getStateValueArray(billingStateCodes);
    Picker.hide();
    Picker.init({
        pickerTitleText: '',
        pickerConfirmBtnText: 'Next',
        pickerCancelBtnText: '',
        pickerBg: [255, 255, 255, 1],
        accessibilityLabel:'guestcheckout_picker_state',
        testID:'guestcheckout_picker_state',
        pickerData: stateVal,
        selectedValue: [stateVal[indexBillingState]],
        pickerFontSize: (Platform.OS === 'ios') ? 18 : 15,
        pickerToolBarFontSize: (Platform.OS === 'ios') ? 18 : 15,
        pickerTextEllipsisLen: 14,
        pickerBtnStyle: { margin: 10 },
        pickerToolBarStyle: { height: 20, paddinBottom: 5 },
        onPickerConfirm: text => {
            if (!this.isValidString(this.state.billingState)) {
                let itemValue = this.getBillingItemValueOfState(billingStateCodes, stateVal[0]);
                this.setState({
                    billingState: itemValue,
                })
            }
            this.refs.State.changeText();
            this.refs.billingZipCde.focus();
        },
        onPickerCancel: stateVal => {
            Picker.hide();
            this.refs.State.changeText();
        },
        onPickerSelect: selectedText => {
            let itemValue = this.getBillingItemValueOfState(billingStateCodes, selectedText);
            this.setState({
                billingState: itemValue
            })
            this.refs.State.changeText();
        }

    });
    Picker.show();
    if (Platform.OS === 'android') {
        this.setState({
            scrollViewHeight: 180
        })
    }
}

0 个答案:

没有答案