diff --git a/detox/src/ios/expect.js b/detox/src/ios/expect.js
index 5f89d9e64e..39cd0e42b7 100644
--- a/detox/src/ios/expect.js
+++ b/detox/src/ios/expect.js
@@ -190,6 +190,15 @@ class TypeTextAction extends Action {
}
}
+
+class ReplaceTextAction extends Action {
+ constructor(value) {
+ super();
+ if (typeof value !== 'string') throw new Error(`ReplaceTextAction ctor argument must be a string, got ${typeof value}`);
+ this._call = invoke.call(invoke.IOS.Class('GREYActions'), 'actionForReplaceText:', value);
+ }
+}
+
class ClearTextAction extends Action {
constructor() {
super();
@@ -355,6 +364,9 @@ class Element {
typeText(value) {
return new ActionInteraction(this, new TypeTextAction(value)).execute();
}
+ replaceText(value) {
+ return new ActionInteraction(this, new ReplaceTextAction(value)).execute();
+ }
clearText() {
return new ActionInteraction(this, new ClearTextAction()).execute();
}
diff --git a/detox/test/e2e/c-actions.js b/detox/test/e2e/c-actions.js
index 869506713c..3c339ca258 100644
--- a/detox/test/e2e/c-actions.js
+++ b/detox/test/e2e/c-actions.js
@@ -36,6 +36,12 @@ describe('Actions', function () {
expect(element(by.label('Clear Working!!!'))).toBeVisible();
});
+ it('should replace text in an element', function () {
+ element(by.id('UniqueId006')).tap();
+ element(by.id('UniqueId006')).replaceText('replaced_text');
+ expect(element(by.label('Replace Working!!!'))).toBeVisible();
+ });
+
// directions: 'up'/'down'/'left'/'right'
it('should scroll for a small amount in direction', function () {
expect(element(by.label('Text1'))).toBeVisible();
diff --git a/detox/test/src/Screens/ActionsScreen.js b/detox/test/src/Screens/ActionsScreen.js
index 16f818fa5d..c0c2c377e7 100644
--- a/detox/test/src/Screens/ActionsScreen.js
+++ b/detox/test/src/Screens/ActionsScreen.js
@@ -49,6 +49,12 @@ export default class ActionsScreen extends Component {
testID='UniqueId005'
/>
+
+
Text1
@@ -106,6 +112,17 @@ export default class ActionsScreen extends Component {
}
}
+ onReplaceText(text) {
+ this.setState({
+ replaceText: text
+ });
+ if (text == 'replaced_text') {
+ this.setState({
+ greeting: 'Replace Working'
+ });
+ }
+ }
+
onChangeClearText(text) {
this.setState({
clearText: text