Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 183727e

Browse files
author
Zdravko
authored
Merge pull request #264 from NativeScript/zbranzov/adb-command
fix: sendKeys command to input properly string with intervals.
2 parents 21cdc41 + efc0932 commit 183727e

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

‎lib/appium-driver.d.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,19 @@ export declare class AppiumDriver {
271271
getScreenViewPort(): IRectangle;
272272
/**
273273
* Android ONLY! Input key event via ADB.
274+
* Must be combined with '--relaxed-security' appium flag. When not running in sauceLabs '--ignoreDeviceController' should be added too.
274275
* @param keyEvent The event number
275276
*/
276277
adbKeyEvent(keyEvent: number | AndroidKeyEvent): Promise<void>;
277278
/**
278279
* Android ONLY! Send text via ADB.
280+
* Must be combined with '--relaxed-security' appium flag. When not running in sauceLabs '--ignoreDeviceController' should be added too.
279281
* @param text The string to send
280282
*/
281283
adbSendText(text: string): Promise<void>;
282284
/**
283285
* Android ONLY! Execute shell command via ADB.
286+
* Must be combined with '--relaxed-security' appium flag. When not running in sauceLabs '--ignoreDeviceController' should be added too.
284287
* @param command The command name
285288
* @param args Additional arguments
286289
*/

‎lib/appium-driver.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,7 @@ export class AppiumDriver {
10271027

10281028
/**
10291029
* Android ONLY! Input key event via ADB.
1030+
* Must be combined with '--relaxed-security' appium flag. When not running in sauceLabs '--ignoreDeviceController' should be added too.
10301031
* @param keyEvent The event number
10311032
*/
10321033
public async adbKeyEvent(keyEvent: number | AndroidKeyEvent) {
@@ -1035,6 +1036,7 @@ export class AppiumDriver {
10351036

10361037
/**
10371038
* Android ONLY! Send text via ADB.
1039+
* Must be combined with '--relaxed-security' appium flag. When not running in sauceLabs '--ignoreDeviceController' should be added too.
10381040
* @param text The string to send
10391041
*/
10401042
public async adbSendText(text: string) {
@@ -1043,6 +1045,7 @@ export class AppiumDriver {
10431045

10441046
/**
10451047
* Android ONLY! Execute shell command via ADB.
1048+
* Must be combined with '--relaxed-security' appium flag. When not running in sauceLabs '--ignoreDeviceController' should be added too.
10461049
* @param command The command name
10471050
* @param args Additional arguments
10481051
*/

‎lib/ui-element.d.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ export declare class UIElement {
126126
hold(time?: number): Promise<void>;
127127
/**
128128
* Send keys to field or other UI component
129-
* @param text
130-
* @param shouldClearText, default value is true
131-
* @param useAdb, default value is false. Usable for Android ONLY !
129+
* @param text The string to input
130+
* @param shouldClearText Clears existing input before send new one - default value is 'true'
131+
* @param useAdb default value is false. Usable for Android ONLY !
132+
* Must be combined with '--relaxed-security' appium flag. When not running in sauceLabs '--ignoreDeviceController' should be added too.
133+
* @param adbDeleteCharsCount default value is 10. Usable for Android ONLY when 'useAdb' and 'shouldClearText' are True!
132134
*/
133-
sendKeys(text: string, shouldClearText?: boolean, useAdb?: boolean): Promise<void>;
135+
sendKeys(text: string, shouldClearText?: boolean, useAdb?: boolean,adbDeleteCharsCount?: number): Promise<void>;
134136
/**
135137
* Type text to field or other UI component
136138
* @param text
@@ -148,6 +150,7 @@ export declare class UIElement {
148150
clearText(): Promise<void>;
149151
/**
150152
* Clears text from ui element with ADB. Android ONLY !
153+
* Must be combined with '--relaxed-security' appium flag. When not running in sauceLabs '--ignoreDeviceController' should be added too.
151154
* @param charactersCount Characters count to delete. (Optional - default value 10)
152155
*/
153156
adbDeleteText(charactersCount?: number): Promise<void>;

‎lib/ui-element.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,18 @@ export class UIElement {
380380

381381
/**
382382
* Send keys to field or other UI component
383-
* @param text
384-
* @param shouldClearText, default value is true
385-
* @param useAdb, default value is false. Usable for Android ONLY !
383+
* @param text The string to input
384+
* @param shouldClearText Clears existing input before send new one - default value is 'true'
385+
* @param useAdb default value is false. Usable for Android ONLY !
386+
* Must be combined with '--relaxed-security' appium flag. When not running in sauceLabs '--ignoreDeviceController' should be added too.
387+
* @param adbDeleteCharsCount default value is 10. Usable for Android ONLY when 'useAdb' and 'shouldClearText' are True!
386388
*/
387-
public async sendKeys(text: string, shouldClearText: boolean = true, useAdb: boolean = false) {
389+
public async sendKeys(text: string, shouldClearText: boolean = true, useAdb: boolean = false,adbDeleteCharsCount: number=10) {
388390
if (useAdb && this._args.isAndroid) {
389391
if (shouldClearText) {
390-
await this.adbDeleteText();
392+
await this.adbDeleteText(adbDeleteCharsCount);
391393
}
394+
text = text.replace(" ","%s");
392395
await this.click();
393396
await adbShellCommand(this._driver, "input", ["text", text]);
394397
} else {
@@ -429,6 +432,7 @@ export class UIElement {
429432

430433
/**
431434
* Clears text from ui element with ADB. Android ONLY !
435+
* Must be combined with '--relaxed-security' appium flag. When not running in sauceLabs '--ignoreDeviceController' should be added too.
432436
* @param charactersCount Characters count to delete. (Optional - default value 10)
433437
*/
434438
public async adbDeleteText(charactersCount: number = 10) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /