UNPKG

913 BJavaScriptView Raw
1const path = require('path');
2const createComponent = require('./createComponent');
3// eslint-disable-next-line
4const { pomConfig } = require(path.join(process.cwd(), process.env.confFile || 'conf.js'));
5
6
7module.exports = (name, world, pageUrl, elLocators, customMethods = {}) =>
8 Object.assign(
9 {},
10 createComponent(name, world, elLocators, 'page'),
11 {
12 getPagePath() {
13 return pageUrl;
14 },
15
16 getPageFullUrl() {
17 // add protocol and host from pomConfig if pageUrl in the page object is just a pathname
18 const url = `${pageUrl.startsWith('http') ? '' : pomConfig.baseUrl}${pageUrl}`;
19
20 console.log('Getting full url: ', url);
21 return url;
22 },
23
24 goToPage() {
25 return browser.get(this.getPageFullUrl());
26 },
27 },
28 customMethods,
29 );
30
31module.exports.getFileName = (fileName) =>
32 path.basename(fileName).replace(/\.js$/, '');