2022-03-21 14:23:50 +01:00
|
|
|
import { Capabilities } from 'selenium-webdriver';
|
2022-10-17 11:42:04 +02:00
|
|
|
import * as chrome from 'selenium-webdriver/chrome';
|
|
|
|
import { LAUNCH_MODE } from './config';
|
2022-03-21 14:23:50 +01:00
|
|
|
|
|
|
|
interface BrowserConfig {
|
|
|
|
appUrl: string;
|
|
|
|
seleniumAddress: string;
|
|
|
|
browserCapabilities: Capabilities;
|
|
|
|
browserOptions: chrome.Options;
|
|
|
|
browserName: string;
|
|
|
|
}
|
|
|
|
|
2022-10-27 17:51:51 +02:00
|
|
|
const chromeArguments = ['--window-size=1024,768', '--use-fake-ui-for-media-stream', '--use-fake-device-for-media-stream'];
|
|
|
|
const chromeArgumentsCI = [
|
2022-12-23 16:17:04 +01:00
|
|
|
'--window-size=1024,768',
|
2022-06-02 17:05:41 +02:00
|
|
|
'--headless',
|
2022-10-17 11:42:04 +02:00
|
|
|
'--no-sandbox',
|
|
|
|
'--disable-gpu',
|
2022-10-27 17:51:51 +02:00
|
|
|
'--disable-popup-blocking',
|
|
|
|
'--no-first-run',
|
|
|
|
'--no-default-browser-check',
|
2022-03-21 14:23:50 +01:00
|
|
|
'--disable-dev-shm-usage',
|
2022-10-27 17:51:51 +02:00
|
|
|
'--disable-background-networking',
|
|
|
|
'--disable-default-apps',
|
2022-03-21 14:23:50 +01:00
|
|
|
'--use-fake-ui-for-media-stream',
|
2022-06-02 13:32:14 +02:00
|
|
|
'--use-fake-device-for-media-stream'
|
2022-03-21 14:23:50 +01:00
|
|
|
];
|
2022-10-27 17:51:51 +02:00
|
|
|
const chromeArgumentsWithoutMediaDevices = ['--window-size=1024,768', '--deny-permission-prompts'];
|
|
|
|
const chromeArgumentsWithoutMediaDevicesCI = [
|
2022-12-23 16:17:04 +01:00
|
|
|
'--window-size=1024,768',
|
2022-10-27 17:51:51 +02:00
|
|
|
'--headless',
|
|
|
|
'--no-sandbox',
|
|
|
|
'--disable-gpu',
|
|
|
|
'--disable-popup-blocking',
|
|
|
|
'--no-first-run',
|
|
|
|
'--no-default-browser-check',
|
|
|
|
'--disable-dev-shm-usage',
|
|
|
|
'--disable-background-networking',
|
|
|
|
'--disable-default-apps',
|
|
|
|
'--deny-permission-prompts'
|
|
|
|
];
|
2022-03-21 14:23:50 +01:00
|
|
|
|
|
|
|
export const WebComponentConfig: BrowserConfig = {
|
|
|
|
appUrl: 'http://localhost:8080/',
|
2022-10-17 11:42:04 +02:00
|
|
|
seleniumAddress: LAUNCH_MODE === 'CI' ? 'http://localhost:3000/webdriver' : '',
|
2022-03-21 14:23:50 +01:00
|
|
|
browserName: 'chrome',
|
|
|
|
browserCapabilities: Capabilities.chrome().set('acceptInsecureCerts', true),
|
2022-11-16 11:35:07 +01:00
|
|
|
browserOptions: new chrome.Options().addArguments(...(LAUNCH_MODE === 'CI' ? chromeArgumentsCI : chromeArguments))
|
2022-03-21 14:23:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export const AngularConfig: BrowserConfig = {
|
2022-06-02 13:32:14 +02:00
|
|
|
appUrl: 'http://localhost:4200/#/testing',
|
2022-10-17 11:42:04 +02:00
|
|
|
seleniumAddress: LAUNCH_MODE === 'CI' ? 'http://localhost:3000/webdriver' : '',
|
2022-03-21 14:23:50 +01:00
|
|
|
browserName: 'Chrome',
|
|
|
|
browserCapabilities: Capabilities.chrome().set('acceptInsecureCerts', true),
|
|
|
|
browserOptions: new chrome.Options().addArguments(...(LAUNCH_MODE === 'CI' ? chromeArgumentsCI : chromeArguments))
|
|
|
|
};
|
2022-10-27 17:51:51 +02:00
|
|
|
|
|
|
|
export function getBrowserOptionsWithoutDevices() {
|
|
|
|
if(LAUNCH_MODE === 'CI') {
|
|
|
|
return new chrome.Options().addArguments(...chromeArgumentsWithoutMediaDevicesCI);
|
|
|
|
} else {
|
|
|
|
return new chrome.Options().addArguments(...chromeArgumentsWithoutMediaDevices);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|