Skip to content

Commit c166c49

Browse files
author
Vasil Chimev
authored
feat: add backgroundApp method (#89)
* feat: add backgroundApp method Send the currently active app to the background. * refactor: add console log to backgroundApp method
1 parent 7e5608a commit c166c49

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/appium-driver.d.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export declare class AppiumDriver {
2424
private _logPath;
2525
private _storageByDeviceName;
2626
private _storageByPlatform;
27-
private constructor(_driver, _wd, _webio, _driverConfig, _args);
27+
private constructor();
2828
readonly imageHelper: ImageHelper;
2929
defaultWaitTime: number;
3030
readonly capabilities: any;
@@ -138,6 +138,11 @@ export declare class AppiumDriver {
138138
logPageSource(fileName: string): Promise<void>;
139139
static createAppiumDriver(port: number, args: INsCapabilities): Promise<AppiumDriver>;
140140
private static applyAdditionalSettings(args);
141+
/**
142+
* Send the currently active app to the background
143+
* @param time
144+
*/
145+
backgroundApp(time: number): Promise<void>;
141146
resetApp(): Promise<void>;
142147
init(): Promise<void>;
143148
quit(): Promise<void>;
@@ -154,12 +159,12 @@ export declare class AppiumDriver {
154159
* @param xPath
155160
* @param waitForElement
156161
*/
157-
findElementByXPathIfExists(xPath: string, waitForElement?: number): Promise<any>;
162+
findElementByXPathIfExists(xPath: string, waitForElement?: number): Promise<UIElement>;
158163
/**
159164
* Search for element by given text but does not throw error if can not find it. Instead returns 'undefined'.
160165
* @param text
161166
* @param match
162167
* @param waitForElement
163168
*/
164-
findElementByTextIfExists(text: string, match?: SearchOptions, waitForElement?: number): Promise<any>;
169+
findElementByTextIfExists(text: string, match?: SearchOptions, waitForElement?: number): Promise<UIElement>;
165170
}

lib/appium-driver.ts

+9
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,15 @@ export class AppiumDriver {
477477
}
478478
}
479479

480+
/**
481+
* Send the currently active app to the background
482+
* @param time
483+
*/
484+
public async backgroundApp(time: number) {
485+
console.log("Sending the currently active app to the background ...");
486+
await this._driver.backgroundApp(time);
487+
}
488+
480489
public async resetApp() {
481490
await this._driver.resetApp();
482491
}

0 commit comments

Comments
 (0)