Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_before(function(done) {
if (onSauce && this.currentTest) {
caps.name = this.currentTest.parent.title + " " + this.currentTest.title;
}
driverHolder.driver = wd.promiseChainRemote(host, port);
if (process.env.VERBOSE) {
driverHolder.driver.on('status', function(info) {
console.log(info);
});
driverHolder.driver.on('command', function(meth, path, data) {
console.log(' > ' + meth, path, data || '');
});
}
driverHolder.driver
.init(caps)
.then(
// ok
function(sessionId) {
driverHolder.sessionId = sessionId;
const setupDriver = async () => {
const branch = process.env.CIRCLE_BRANCH || '';
const safeBranchName = branch.replace( /\//g, '-' );
if ( isLocalEnvironment() ) {
try {
appiumProcess = await AppiumLocal.start( localAppiumPort );
} catch ( err ) {
// Ignore error here, Appium is probably already running (Appium desktop has its own server for instance)
// eslint-disable-next-line no-console
console.log( 'Could not start Appium server', err.toString() );
}
}
const serverConfig = isLocalEnvironment() ? serverConfigs.local : serverConfigs.sauce;
const driver = wd.promiseChainRemote( serverConfig );
let desiredCaps;
if ( isAndroid() ) {
desiredCaps = _.clone( android8 );
if ( isLocalEnvironment() ) {
desiredCaps.app = path.resolve( localAndroidAppPath );
try {
const androidVersion = childProcess
.execSync( 'adb shell getprop ro.build.version.release' )
.toString()
.replace( /^\s+|\s+$/g, '' );
delete desiredCaps.platformVersion;
desiredCaps.deviceName = 'Android Emulator';
// eslint-disable-next-line no-console
console.log( 'Detected Android device running Android %s', androidVersion );
} catch ( error ) {
var createClient = function createClient() {
var res = wd.promiseChainRemote('localhost', process.env.LOCAL_SELENIUM_PORT || 4444)
.init(automatedBrowsers.phantomjs.driver.config)
.setWindowSize(1000, 1000) // do something
.quit();
return res;
};
before(function(done) {
browser = wd.promiseChainRemote(host, port, username, accessKey);
// See whats going on
browser.on('status', function(info) {
console.log(info.cyan);
});
browser.on('command', function(meth, path, data) {
console.log(' > ' + meth.yellow, path.grey, data || '');
});
browser
.init(desired)
.nodeify(done);
});
import wd from 'wd';
import config from '../e2e.config';
const port = 4723;
const driver = wd.promiseChainRemote('localhost', port);
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
const tapElementByAccessibilityId = async (id) => {
const button = await driver.elementByAccessibilityId(id);
await button.tap();
};
describe('TabNavigation', () => {
// timeout(200000)
beforeAll(async () => {
await driver.init(config);
while (!await driver.hasElementByAccessibilityId('nav bar')) {
await driver.sleep(1000); // wait for app to load
}
});
sauceConnectLauncher(options, function (err, process) {
if (err) {
console.error('Failed to connect to saucelabs');
console.error(err);
return process.exit(1);
}
sauceConnectProcess = process;
sauceClient = wd.promiseChainRemote("localhost", 4445, username, accessKey);
callback();
});
}
it('should start and stop a session', async function () {
let driver = wd.promiseChainRemote(TEST_HOST, TEST_PORT);
let [sessionId] = await driver.init(caps);
should.exist(sessionId);
sessionId.should.be.a('string');
await driver.quit();
await driver.title().should.eventually.be.rejectedWith(/terminated/);
});
module.exports.attachToSession = function (sessionId) {
var browser = wd.promiseChainRemote(env.APPIUM_HOST, env.APPIUM_PORT, env.APPIUM_USERNAME, env.APPIUM_PASSWORD);
browser.attach(sessionId);
return browser;
};
request(SELENIUM_HUB, function (err, resp) {
if (resp && resp.statusCode === 200) {
sauceClient = wd.promiseChainRemote();
callback();
} else {
setTimeout(started, 1000);
}
});
};