@serenity-js/protractor
Version:
Adapter that integrates @serenity-js/web with Protractor, enabling Serenity/JS reporting and using the Screenplay Pattern to write end-to-end test scenarios
48 lines • 1.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StandardisedCapabilities = void 0;
/**
* @private
*/
class StandardisedCapabilities {
currentBrowser;
static of(currentBrowser) {
return new StandardisedCapabilities(currentBrowser);
}
constructor(currentBrowser) {
this.currentBrowser = currentBrowser;
}
browserName() {
return this.get(caps => caps.get('browserName'));
}
async browserVersion() {
const version = await this.get(caps => caps.get('version'), caps => caps.get('browserVersion'), caps => caps.has('deviceManufacturer') && caps.has('deviceModel')
? `${caps.get('deviceManufacturer')} ${caps.get('deviceModel')}`
: undefined, caps => caps.has('mobile') && caps.get('mobile').version);
const suffix = await this.get(caps => !!caps.get('mobileEmulationEnabled') && '(mobile emulation)');
return [
version,
suffix,
].filter(_ => !!_).join(' ');
}
platformName() {
return this.get(caps => (!!caps.get('platformName') && !/any/i.test(caps.get('platformName')))
? caps.get('platformName')
: caps.get('platform'));
}
platformVersion() {
return this.get(caps => caps.get('platformVersion'));
}
async get(...fetchers) {
const capabilities = await this.currentBrowser().getCapabilities();
for (const fetcher of fetchers) {
const result = fetcher(capabilities);
if (result) {
return result;
}
}
return undefined; // eslint-disable-line unicorn/no-useless-undefined
}
}
exports.StandardisedCapabilities = StandardisedCapabilities;
//# sourceMappingURL=StandardisedCapabilities.js.map