Reputation: 47
I am able to call baseUrl from one page object file but i am not able to call schoolUrl from another page object file. I am trying to call url from config file without adding whole url in page object file.
My config.js file is
exports.config = {
allScriptsTimeout: 11000,
restartBrowserBetweenTests: true,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
framework: 'jasmine2',
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
args: ["--start-maximized", "--window-size=1630,963"]
}
},
directConnect: true,
port: null,
baseUrl: 'https://class.com',
schoolUrl: 'https://school.com'
}
my page object file to call baseUrl
import {browser, by, element, ElementFinder, ExpectedConditions, promise} from 'protractor';
export class SchoolPage {
public staffUrl = '';
public async navigateTo(): Promise<any> {
return browser.get(``) ;
}
How can i call schoolUrl from config.js file like base url is called directly without adding url in po file
Upvotes: -1
Views: 77
Reputation: 8948
If you add this to your config
exports.config = {
allScriptsTimeout: 11000,
restartBrowserBetweenTests: true,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
framework: 'jasmine2',
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
args: ["--start-maximized", "--window-size=1630,963"]
}
},
directConnect: true,
port: null,
baseUrl: 'https://class.com',
params: {
schoolUrl: 'https://school.com'
},
}
then you can refer to that variable in your code like this browser.params.schoolUrl
Upvotes: 0