Skip to content

Commit bcf6434

Browse files
author
Zdravko
authored
fix: isDisplayed to check actual coordinates whether elem is visible on the screen (#153)
1 parent 189ba64 commit bcf6434

File tree

7 files changed

+28
-22
lines changed

7 files changed

+28
-22
lines changed

lib/appium-driver.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export declare class AppiumDriver {
163163
*/
164164
startRecordingVideo(videoName: any): any;
165165
stopRecordingVideo(): Promise<any>;
166-
private compare;
166+
private compare(imageName, timeOutSeconds?, tolerance?, rect?, toleranceType?);
167167
prepareImageToCompare(filePath: string, rect: IRectangle): Promise<void>;
168168
takeScreenshot(fileName: string): Promise<string>;
169169
logScreenshot(fileName: string): Promise<string>;
@@ -183,10 +183,10 @@ export declare class AppiumDriver {
183183
resetApp(): Promise<void>;
184184
init(): Promise<void>;
185185
quit(): Promise<void>;
186-
private static applyAdditionalSettings;
187-
private convertArrayToUIElements;
188-
private static configureLogging;
189-
private getExpectedImagePath;
186+
private static applyAdditionalSettings(args);
187+
private convertArrayToUIElements(array, searchM, args);
188+
private static configureLogging(driver, verbose);
189+
private getExpectedImagePath(imageName);
190190
/**
191191
* Wait specific amount of time before continue execution
192192
* @param miliseconds

lib/appium-server.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export declare class AppiumServer {
1515
readonly server: child_process.ChildProcess;
1616
hasStarted: boolean;
1717
start(port: any, deviceManager?: IDeviceManager): Promise<boolean | this>;
18-
private startAppiumServer;
18+
private startAppiumServer(logLevel, isSauceLab);
1919
stop(): Promise<{}>;
20-
private prepDevice;
21-
private prepApp;
22-
private resolveAppiumDependency;
20+
private prepDevice(deviceManager);
21+
private prepApp();
22+
private resolveAppiumDependency();
2323
}

lib/image-helper.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export declare class ImageHelper {
1818
width: any;
1919
height: any;
2020
};
21-
private static getOffsetPixels;
22-
private runDiff;
21+
private static getOffsetPixels(args);
22+
private runDiff(diffOptions, diffImage);
2323
compareImages(actual: string, expected: string, output: string, valueThreshold?: number, typeThreshold?: any): Promise<boolean>;
2424
clipRectangleImage(rect: IRectangle, path: string): Promise<{}>;
2525
readImage(path: string): Promise<any>;

lib/locators.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export declare class Locator {
88
readonly image: string;
99
readonly locators: Map<string, string>;
1010
getElementByName(name: any): string;
11-
private loadAndroidElements;
12-
private loadIOSElements;
13-
private createIosElement;
11+
private loadAndroidElements();
12+
private loadIOSElements();
13+
private createIosElement(element);
1414
}

lib/ns-capabilities.d.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export declare class NsCapabilities implements INsCapabilities {
3737
private _device;
3838
private _deviceManager;
3939
private _exceptions;
40+
private _imagesPath;
4041
constructor(_parser: INsCapabilitiesArgs);
4142
readonly path: string;
4243
readonly projectDir: string;
@@ -70,13 +71,14 @@ export declare class NsCapabilities implements INsCapabilities {
7071
readonly startSession: boolean;
7172
deviceManager: IDeviceManager;
7273
readonly isValidated: boolean;
74+
readonly imagesPath: string;
7375
extend(args: INsCapabilities): this;
7476
validateArgs(): void;
75-
private isAndroidPlatform;
76-
private shouldSetFullResetOption;
77-
private setAutomationName;
77+
private isAndroidPlatform();
78+
private shouldSetFullResetOption();
79+
private setAutomationName();
7880
tryGetAndroidApiLevel(): number;
79-
private resolveApplication;
80-
private checkMandatoryCapabiliies;
81-
private throwExceptions;
81+
private resolveApplication();
82+
private checkMandatoryCapabiliies();
83+
private throwExceptions();
8284
}

lib/ui-element.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export declare class UIElement {
99
private _args;
1010
private _searchMethod;
1111
private _searchParams;
12-
private _index?;
12+
private _index;
1313
constructor(_element: any, _driver: any, _wd: any, _webio: any, _args: INsCapabilities, _searchMethod: string, _searchParams: string, _index?: number);
1414
/**
1515
* Click on element

lib/ui-element.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,19 @@ export class UIElement {
9292
* Shows if element is displayed. Returns true or false. If the element doesn't exist it will return false
9393
*/
9494
public async isDisplayed() {
95+
const displaySize = await this._driver.getWindowSize();
9596
const el = (await this.element());
9697
let isDisplayed = true;
9798
if (!el || el === null) {
9899
return false;
99100
}
100101

101102
try {
102-
isDisplayed = (await el.isDisplayed());
103+
const elemCoordinates = await this.getRectangle();
104+
isDisplayed = (await el.isDisplayed()) && elemCoordinates.x >= 0 && elemCoordinates.x < displaySize.width
105+
&& elemCoordinates.y >= 0 && elemCoordinates.y < displaySize.height;
103106
} catch (error) {
107+
console.log("ERROR: " + error);
104108
isDisplayed = false;
105109
}
106110

0 commit comments

Comments
 (0)