Skip to content

Commit aff491d

Browse files
fix: backward compatability for setValue command (#79)
* fix: backward compatability for setValue command * add test * fix linting * add linting fixes to test * fix unit tests
1 parent 7418351 commit aff491d

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"clean": "rimraf package-lock.json && rimraf node_modules && npm install",
4040
"build": "rimraf build && tsc",
4141
"watch": "tsc --watch",
42-
"prettier": "prettier 'src/**/*.ts' --write --single-quote",
42+
"prettier": "prettier 'src/**/*.ts' 'test/**/*.*' --write --single-quote",
4343
"prettier-check": "prettier 'src/**/*.ts' 'test/**/*.*' --check",
4444
"appium-home": "rm -rf /tmp/some-temp-dir && export APPIUM_HOME=/tmp/some-temp-dir",
4545
"test": "NODE_OPTIONS='--loader ts-node/esm' mocha --require ts-node/register test/**/*.ts",

src/commands/element.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export async function setValue(
8383
) {
8484
const driver = ELEMENT_CACHE.get(elementId);
8585
return await driver.command(`/element/${elementId}/value`, 'POST', {
86-
text,
86+
text: text && _.isArray(text) ? text.join('') : text, // text should always be a string
87+
value: text && _.isString(text) ? [...text] : text, // value should always be a array of char
8788
});
8889
}
8990

test/specs/test.e2e.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ async function performLogin(userName = 'admin', password = '1234') {
55
const att = await browser.flutterByValueKey$('username_text_field');
66
console.log(await att.getAttribute('all'));
77
await browser.flutterByValueKey$('username_text_field').clearValue();
8-
await browser.flutterByValueKey$('username_text_field').addValue(userName);
8+
await $(
9+
'//android.view.View[@content-desc="username_text_field"]/android.widget.EditText',
10+
).addValue(userName);
911

1012
await browser.flutterByValueKey$('password_text_field').clearValue();
1113
await browser.flutterByValueKey$('password').addValue(password);

test/unit/element.specs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ describe('Element Interaction Functions', () => {
222222
mockDriver.command.calledWith(
223223
`/element/${elementId}/value`,
224224
'POST',
225-
{ text },
225+
{ text, value: [...text] },
226226
),
227227
).to.be.true;
228228
});

0 commit comments

Comments
 (0)