Reactjs 反应本机+;Appium iOS TextInput.clear()
以下是我用React Native中的Appium在Android上清除输入的代码:Reactjs 反应本机+;Appium iOS TextInput.clear(),reactjs,react-native,appium,Reactjs,React Native,Appium,以下是我用React Native中的Appium在Android上清除输入的代码: driver.elementByAccessibilityId(inputName) 。然后(输入=>input.click() 。然后(()=>input.clear()) input.click()存在,因为input.clear()似乎没有选择Android中的文本字段;这种变通方法在Android上运行良好 但是,input.click()在iOS上似乎没有任何作用。是否有人找到了解决方法?我的解决方
driver.elementByAccessibilityId(inputName)
。然后(输入=>input.click()
。然后(()=>input.clear())
input.click()
存在,因为input.clear()
似乎没有选择Android中的文本字段;这种变通方法在Android上运行良好
但是,
input.click()
在iOS上似乎没有任何作用。是否有人找到了解决方法?我的解决方法是:发送与文本输入中的字符数量相同的退格
您必须知道TextInput
中的文本是什么,不幸的是,由于。如果有人想使用它,下面是我的完整代码:
import {Platform} from 'react-native';
/**
* @param {string} inputName Name of element
* @param {string} value Value previously in the input, used by iOS.
* @returns {() => Promise}
*/
function clearInput(inputName, value) {
if (Platform.OS === 'android') {
return () => driver.elementByAccessibilityId(inputName)
.then(input => input.click()
.then(() => input.clear()))
.then(() => driver.hideDeviceKeyboard());
}
else {
return () => driver.elementByAccessibilityId(inputName)
.then(input => input.type('\b'.repeat(value.length)))
.then(() => driver.hideDeviceKeyboard());
}
}
我仍然想知道你是否有办法在iOS中实现这一点,或者这只是Appium的一个bug