Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function runTests(caps) {
var driver = new webdriver.Builder().usingServer(url).withCapabilities(caps).build();
var roomname = ''
/*
Checking if the socket connection is established correctly and existing messages are loaded without errors (this is done by initializing the DB with some initial test data).
Sending a message as a guest user.
Logging in (assertion for a nick change here).
Sending a message as a logged in user.
Logging out.
Changing the user nick.
Test to check if plug ins are working correctly : (Banned words, Repetitive messages)
Logging in from archive view.
Logging out from archive view.
Sending a message from archive view (This test case is currently not working).
*/
// Load a nonexistent scrollback room
function _testInjectedDriver(browserName, serverUrl, next) {
var webdriver = require('selenium-webdriver');
var browser = webdriver.Capabilities.firefox();
var driver = new webdriver.Builder()
.usingServer(serverUrl)
.withCapabilities(browser)
.build();
huxley.injectDriver(function() {
return driver;
});
_testPasses(browserName, serverUrl, function(err) {
if (err) return next(false);
next();
// Erase the injected driver. Just for sure, that we didn't broke next test.
huxley.injectDriver(null);
});
}
this.chromeOptions.addArguments('--disable-translate');
this.chromeOptions.addArguments('--safebrowsing-disable-auto-update');
if (this.options.headless) {
this.chromeOptions.addArguments('--headless', '--no-sandbox');
if (isWin) {
// Temporarily needed on Windows
this.chromeOptions.addArguments('--disable-gpu');
}
}
this.chromeOptions.addArguments(`--user-agent=${this.options.userAgent || DEFAULT_USER_AGENT}`);
if (this.options.extraChromeArguments) {
this.chromeOptions.addArguments(this.options.extraChromeArguments);
}
this.builder = new Builder();
// Instance of Selenium's WebDriver
this.webDriver = null;
}
export async function StartDriver(proxy?: ProxyConfig) {
let options = new chrome.Options();
if (process.env['HEADLESS'] == 'y') {
options = options.headless();
}
let driverBuilder = new SeleniumWebdriver.Builder()
.forBrowser("chrome");
if (proxy) {
options = options.addArguments(`--proxy-server=${proxy.httpProxy}`)
}
driverBuilder = driverBuilder.setChromeOptions(options);
return await driverBuilder.build();
}
createNewDriver: function() {
var caps = this._getCapabilities();
var hubUrl = this._getHubUrl();
var driver = new webdriver.Builder().
withCapabilities(caps).
usingServer(hubUrl).
build();
return driver;
},
before(() => {
SERVER_URL = getServerUrl();
driver = new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.firefox())
.build();
});
before(async () => {
driver = new webdriver.Builder()
.forBrowser('chrome')
.withCapabilities(capabilities)
.build();
await driver.manage().setTimeouts({pageLoad: 120000});
})
function driver() {
const driver_builder = new Builder()
.forBrowser('chrome')
.setChromeOptions(chrome_options);
return driver_builder.build();
}
function getDriverInstance() {
const driver = new webdriver.Builder()
.usingServer(config.selenium.remoteURL)
.withCapabilities(config.selenium.caps)
.build();
return driver;
}
caps.set('applicationCacheEnabled', false);
switch (__config.browser.toLowerCase()) {
case "chrome":
global.__wdriver = new Builder()
.withCapabilities(caps)
.forBrowser(__config.browser)
.setChromeOptions(new chrome.Options().headless()
.addArguments(chromeArguments)
.setUserPreferences(chromeUserPreferences)
.setLoggingPrefs(logPrefs)
.windowSize({width: windowSize.width, height: windowSize.height}))
.build();
break;
case "firefox":
global.__wdriver = new Builder()
.forBrowser(__config.browser)
.setFirefoxOptions(new ffox.Options().headless().windowSize({width: windowSize.width,
height: windowSize.height}))
.build();
break;
}
}else{
switch (__config.browser.toLowerCase()) {
case "chrome":
global.__wdriver = new Builder()
.withCapabilities(caps)
.forBrowser(__config.browser)
.setChromeOptions(new chrome.Options().addArguments("--incognito")
.addArguments(chromeArguments)
.setUserPreferences(chromeUserPreferences)