/** * Creates a webdriver instance based on config (remote connection) * @returns {webdriver} selenium webdriver */ function getDriverInstance() { const driver = new webdriver.Builder() .usingServer(config.selenium.remoteURL) .withCapabilities(config.selenium.caps) .build(); return driver; }
/** * Sets up a chrome driver we can use to fetch a webpage and test * that is the object to add the driver to */ function setupChrome(that) { chrome.setDefaultService( new chrome.ServiceBuilder(chromedriver.path).build() ); that.driver = new seleniumWebdriver.Builder() .withCapabilities(seleniumWebdriver.Capabilities.chrome()) .build(); }
function CustomWorld() { this.driver = new webdriver.Builder() .forBrowser('chrome') .build(); }
function startBrowser(browserName, cdriverArgs) { browser = browserName || browser; chromedriverArgs = cdriverArgs || chromedriverArgs; chromedriver.start(chromedriverArgs); driver = new Webdriver.Builder() .forBrowser(browser) .build(); }
static create(chromePath, headless) { const args = [ "--disable-extensions", "--window-size=1366,768", "--no-sandbox", // required for Linux without GUI "--disable-gpu", // required for Windows, "--enable-logging --v=1", // write debug logs to file(debug.log) ]; if (headless) { args.push("--headless") } const chromeCapabilities = selenium.Capabilities.chrome() .set('chromeOptions', { args }) .set("chrome.binary", chromePath) .set("acceptInsecureCerts", true); // if you render localhost with SSL const builder = new selenium.Builder() .forBrowser('chrome') .withCapabilities(chromeCapabilities); return builder.build().then(driver => new Renderer(driver)); }
before( // eslint-disable-line no-undef function () { var newAuthHelperFileContent; // Read variables from testConfig.json file var configFilePath = path.join(__dirname, 'testConfig.json'); var config = JSON.parse(fs.readFileSync(configFilePath, { encoding: 'utf8' })); clientId = config.test_client_id_v2; clientSecret = config.test_client_secret_v2; username = config.test_username; password = config.test_password; // Rewrite authHelper.js file to include the credentials from testConfig file filePath = path.join(__dirname, '../authHelper.js'); authHelperFileContent = fs.readFileSync(filePath, { encoding: 'utf8' }); newAuthHelperFileContent = authHelperFileContent.replace('ENTER_YOUR_CLIENT_ID', clientId); newAuthHelperFileContent = newAuthHelperFileContent.replace('ENTER_YOUR_SECRET', clientSecret); fs.writeFileSync(filePath, newAuthHelperFileContent, { encoding: 'utf8' }); // Start node app require('../bin/www'); // eslint-disable-line global-require driver = new webdriver.Builder() .withCapabilities(webdriver.Capabilities.chrome()) .build(); } );
describe('Instant Sauce Test Module 2', function() { beforeEach(async function () { driver = await new webdriver.Builder().withCapabilities({ 'browserName': 'safari', 'platformName': 'macOS 10.13',
describe('Instant Sauce Test Module 2', function() { this.timeout(40000); beforeEach(async function () { driver = await new webdriver.Builder().withCapabilities({ 'browserName': 'safari', 'platformName': 'macOS 10.13',
driver = new webdriver.Builder().withCapabilities({ 'browserName': 'safari', 'platformName': 'macOS 10.13',
before( // eslint-disable-line no-undef function () { var newAuthHelperFileContent; // Read variables from testConfig.json file var configFilePath = path.join(__dirname, 'testConfig.json'); var config = JSON.parse(fs.readFileSync(configFilePath, { encoding: 'utf8' })); clientId = config.test_client_id_v2; clientSecret = config.test_client_secret_v2; username = config.test_username; password = config.test_password; // Rewrite authHelper.js file to include the credentials from testConfig file filePath = path.join(__dirname, '../authHelper.js'); authHelperFileContent = fs.readFileSync(filePath, { encoding: 'utf8' }); newAuthHelperFileContent = authHelperFileContent.replace('ENTER_YOUR_CLIENT_ID', clientId); newAuthHelperFileContent = newAuthHelperFileContent.replace('ENTER_YOUR_SECRET', clientSecret); fs.writeFileSync(filePath, newAuthHelperFileContent, { encoding: 'utf8' }); // Start node app require('../bin/www'); // eslint-disable-line global-require driver = new webdriver.Builder() .withCapabilities(webdriver.Capabilities.chrome()) .build(); } );
describe('Instant Sauce Test Module 2', function() { beforeEach(async function () { driver = await new webdriver.Builder().withCapabilities({ 'browserName': 'safari', 'platformName': 'macOS 10.13',
describe('Instant Sauce Test Module 2', function() { this.timeout(40000); beforeEach(async function () { driver = await new webdriver.Builder().withCapabilities({ 'browserName': 'safari', 'platformName': 'macOS 10.13',
driver = await new webdriver.Builder().withCapabilities({ 'browserName': 'chrome', 'platformName': 'Windows 10',
driver = new webdriver.Builder().withCapabilities({ 'browserName': 'safari', 'platformName': 'macOS 10.13',
describe ('headless chrome test', function() { this.timeout(40000); beforeEach(async function () { driver = await new webdriver.Builder().withCapabilities({ 'browserName': 'chrome', 'platformName': 'linux',