Skip to content

Commit 9b18789

Browse files
committed
fix undefined variables
1 parent 5c62948 commit 9b18789

File tree

2 files changed

+28
-32
lines changed

2 files changed

+28
-32
lines changed

es6/commands/saveElementScreenshot.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,48 +31,46 @@ import easyimg from 'easyimage';
3131

3232
class SaveElementScreenshotAction extends events.EventEmitter {
3333
command(elementSelector, fileName, defaultMessage) {
34-
if (defaultMessage && typeof defaultMessage !== 'string') {
35-
this.emit('error', "defaultMessage is not a string");
36-
return;
37-
}
38-
34+
this.elementSelector = elementSelector;
35+
this.fileName = fileName;
36+
this.defaultMessage = defaultMessage;
37+
3938
this.api.getElementSize(elementSelector, sizeResult => {
4039
return this.api.getLocation(elementSelector, locationResult => {
4140
return this.api.saveScreenshot(fileName, () => {
42-
return this.crop(fileName, sizeResult.value, locationResult.value);
41+
this.crop(sizeResult.value, locationResult.value);
4342
});
4443
});
4544
});
4645

4746
return this;
4847
}
4948

50-
crop(fileName, size, location) {
51-
easyimg.crop({
52-
src: fileName,
53-
dst: fileName,
49+
crop(size, location) {
50+
return easyimg.crop({
51+
src: this.fileName,
52+
dst: this.fileName,
5453
cropwidth: size.width,
5554
cropheight: size.height,
5655
x: location.x,
5756
y: location.y,
5857
gravity: 'North-West'
5958
}).then(
6059
file => {
61-
let message = `Saved screenshot for <${elementSelector}> to ${fileName}`;
62-
if (defaultMessage) {
63-
message = defaultMessage;
60+
let message = `Saved screenshot for <${this.elementSelector}> to ${this.fileName}`;
61+
if (this.defaultMessage) {
62+
message = this.defaultMessage;
6463
}
6564

66-
this.client.assertion(result, 'expression false', 'expression true', message, true);
65+
this.client.assertion(true, 'expression false', 'expression true', message, true);
6766
return this.emit("complete");
6867
},
6968
err => {
70-
this.emit('error', `SaveElementScreenshotAction: could not save screenshot (error is ${err})`);
71-
return this.emit("complete");
69+
return this.emit('error', `SaveElementScreenshotAction: could not save screenshot (error is ${err})`);
7270
}
7371
);
7472

7573
}
7674
}
7775

78-
export default SaveElementScreenshotAction;
76+
export default SaveElementScreenshotAction;

js/commands/saveElementScreenshot.js

Lines changed: 13 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)