Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const firefoxOptions = new firefox.Options();
// Firefox 65+ supports logging console output to stdout
firefoxOptions.set('moz:firefoxOptions', {
prefs: { 'devtools.console.stdout.content': true },
});
if (headlessBrowser === '1') {
// See: https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode
firefoxOptions.headless();
}
// Windows issue with stout socket https://github.com/elastic/kibana/issues/52053
if (process.platform === 'win32') {
const session = await new Builder()
.forBrowser(browserType)
.setFirefoxOptions(firefoxOptions)
.setFirefoxService(new firefox.ServiceBuilder(geckoDriver.path))
.build();
return {
session,
consoleLog$: Rx.EMPTY,
};
}
const { input, chunk$, cleanup } = await createStdoutSocket();
lifecycle.on('cleanup', cleanup);
const session = await new Builder()
.forBrowser(browserType)
.setFirefoxOptions(firefoxOptions)
.setFirefoxService(
new firefox.ServiceBuilder(geckoDriver.path).setStdio(['ignore', input, 'ignore'])
)
module.exports = {
src_folders: ['test/e2e/specs'],
output_folder: 'test/e2e/reports',
custom_commands_path: ['node_modules/nightwatch-helpers/commands'],
custom_assertions_path: ['node_modules/nightwatch-helpers/assertions'],
// set to true when testing on multiple browsers (-e chrome,firefox) to display tests as they pass instead of waiting for everything to be finished
live_output: false,
selenium: {
start_process: true,
server_path: require('selenium-server').path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': require('chromedriver').path,
'webdriver.gecko.driver': require('geckodriver').path
}
},
test_settings: {
default: {
selenium_port: 4444,
selenium_host: 'localhost',
silent: true,
screenshots: {
enabled: true,
on_failure: true,
on_error: false,
path: 'test/e2e/screenshots'
},
desiredCapabilities: {
browserName: 'chrome',
src_folders: [`${projectRoot}/test/e2e/`],
output_folder: `${projectRoot}/reports/e2e/${utils.reportsDir}/`,
custom_commands_path: '',
custom_assrtions_path: '',
page_objects_path: 'test/e2e/pages',
globals_path: 'config/nightwatch/globals.js',
selenium: {
start_process: false,
server_path: './node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar',
log_path: `${projectRoot}/reports/e2e/`,
host: '127.0.0.1',
port: 4444,
silent: true,
cli_args: {
'webdriver.chrome.driver': require('chromedriver').path,
'webdriver.gecko.driver': require('geckodriver').path
}
},
// 'test_workers': {'enabled': true, 'workers': 'auto'},
test_settings: {
default: {
launch_url: 'http://localhost',
selenium_port: process.env.CIRCLE_ENV ? 80 : 4444,
selenium_host: process.env.CIRCLE_ENV ? 'ondemand.saucelabs.com' : 'localhost',
silent: true,
screenshots: {
enabled: true,
path: projectRoot + `/reports/e2e/${utils.reportsDir}/screenshots`,
on_failure: true,
on_error: true
},
globals: {
const test = async function() {
console.log('Starting Geckodriver...');
geckodriver.start();
console.log('Running functional tests...');
try {
childProcess.execFileSync(
'poetry', ['run', 'pytest'],
{cwd: FUNC_TEST_PATH, stdio: 'inherit'},
);
} finally {
console.log('Stopping Geckodriver...');
geckodriver.stop();
}
};
const test = async function() {
console.log('Starting Geckodriver...');
geckodriver.start();
console.log('Running functional tests...');
try {
childProcess.execFileSync(
'poetry', ['run', 'pytest'],
{cwd: FUNC_TEST_PATH, stdio: 'inherit'},
);
} finally {
console.log('Stopping Geckodriver...');
geckodriver.stop();
}
};
},
chrome: {
webdriver: {
server_path: chromedriver.path,
cli_args: ['--port=4444']
},
desiredCapabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
w3c: false
}
}
},
firefox: {
webdriver: {
server_path: geckodriver.path,
cli_args: ['--port', '4444', '--log', 'debug']
},
desiredCapabilities: {
browserName: 'firefox',
marionette: true
}
}
}
};
server_path: require('chromedriver').path,
log_path: './e2e_tests/log'
}
},
firefox: {
desiredCapabilities : {
browserName : 'firefox',
acceptInsecureCerts: true,
acceptSslCerts : true,
ignoreProtectedModeSettings: true,
unexpectedAlertBehaviour: 'accept'
},
webdriver: {
start_process: true,
port: 4444,
server_path: require('geckodriver').path,
log_path: './e2e_tests/log'
}
}
}
};
const startBrowser = () => {
switch (TARGET_BROWSER) {
case 'chrome':
chromedriver.start();
return () => chromedriver.stop();
case 'firefox':
geckodriver.start();
return () => geckodriver.stop();
default:
throw new Error(`${TARGET_BROWSER} browser driver is not configured`);
}
};
return () => geckodriver.stop();
default:
webdriver: {
server_path: chromedriver.path,
cli_args: ['--port=4444']
},
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
args: ['disable-gpu']
}
}
},
firefox: {
webdriver: {
server_path: geckodriver.path,
cli_args: ['--port', '4444', '--log', 'debug']
},
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true,
marionette: true
}
}
}
};