1 | const path = require('path');
|
2 | const createComponent = require('./createComponent');
|
3 |
|
4 | const { pomConfig } = require(path.join(process.cwd(), process.env.confFile || 'conf.js'));
|
5 |
|
6 |
|
7 | module.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 |
|
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 |
|
31 | module.exports.getFileName = (fileName) =>
|
32 | path.basename(fileName).replace(/\.js$/, '');
|