Files
appium/sample-code/javascript-wd/test/basic/ios-create-session.test.js
Isaac A. Murchie 4ccc8665f8 Begin running sample code in CI (#12519)
* Make stage in Travis to run wd sample code

* Clean up wd sample code for Sauce runs

* Restrict to master/non-PR builds
2019-04-23 12:58:42 -04:00

54 lines
1.5 KiB
JavaScript

import wd from 'wd';
import chai from 'chai';
import {
iosCaps, serverConfig, iosTestApp, SAUCE_TESTING, SAUCE_USERNAME,
SAUCE_ACCESS_KEY
} from '../helpers/config';
const {assert} = chai;
describe('Create session', function () {
let driver;
let allPassed = true;
afterEach(function () {
// keep track of whether all the tests have passed, since mocha does not do this
allPassed = allPassed && (this.currentTest.state === 'passed');
});
after(async function () {
if (SAUCE_TESTING && driver) {
await driver.sauceJobStatus(allPassed);
}
});
it('should create and destroy iOS sessions', async function () {
try {
// Connect to Appium server
driver = SAUCE_TESTING
? await wd.promiseChainRemote(serverConfig)
: await wd.promiseChainRemote(serverConfig, SAUCE_USERNAME, SAUCE_ACCESS_KEY);
// add the name to the desired capabilities
const sauceCaps = SAUCE_TESTING
? {
name: 'iOS Create Session Test',
}
: {};
// Start the session
await driver.init({
...iosCaps,
...sauceCaps,
app: iosTestApp,
});
// Check that the XCUIElementTypeApplication was what we expect it to be
const applicationElement = await driver.elementByClassName('XCUIElementTypeApplication');
const applicationName = await applicationElement.getAttribute('name');
assert.equal(applicationName, 'TestApp');
} finally {
// Quit the session, no matter what happens
await driver.quit();
}
});
});