Skip to content

Commit

Permalink
fix(protractor): fallback to platformName if platform is missing (#456)
Browse files Browse the repository at this point in the history
fix crash when running takeImageOf in IE11
  • Loading branch information
T-Wizard authored and stoffeastrom committed Apr 17, 2019
1 parent 682b616 commit 91a9951
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
20 changes: 10 additions & 10 deletions commands/protractor/src/plugins/screenshoter/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ const utils = {
};
}));
})
.then(meta => this.getBrowserName(browser).then(caps => ({
img: meta.img,
rect: meta.rect,
browserName: caps.get('browserName').replace(' ', '-'),
artifactsPath: browser.reporterInfo.artifactsPath,
platform: caps
.get('platform')
.replace(/ /g, '-')
.toLowerCase(),
})));
.then(meta => this.getBrowserName(browser).then((caps) => {
const platform = caps.get('platform') || caps.get('platformName') || 'unknown';
return {
img: meta.img,
rect: meta.rect,
browserName: caps.get('browserName').replace(' ', '-'),
artifactsPath: browser.reporterInfo.artifactsPath,
platform: platform.replace(/ /g, '-').toLowerCase(),
};
}));
},
};

Expand Down
16 changes: 16 additions & 0 deletions commands/protractor/test/unit/plugins/screenshoter/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,21 @@ describe('Screenshoter Utils', () => {
});
expect(result.browserName).to.equal('chrome');
}));

it('should work with IE11 capabilities', async () => {
Capabilities.delete('platform');
Capabilities.set('platform', 'windows');
Capabilities.set('browserName', 'internet explorer');
const result = await utils.takeImageOf(browser, {});

expect(result.rect).to.deep.equal({
top: 100,
left: 200,
width: 200,
height: 100,
});
expect(result.browserName).to.equal('internet-explorer');
expect(result.platform).to.equal('windows');
});
});
});

0 comments on commit 91a9951

Please sign in to comment.