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
This commit is contained in:
Isaac A. Murchie
2019-04-23 12:58:42 -04:00
committed by GitHub
parent 6e4a0e6480
commit 4ccc8665f8
12 changed files with 395 additions and 149 deletions
@@ -1,28 +1,54 @@
import wd from 'wd';
import chai from 'chai';
import { iosCaps, serverConfig } from '../helpers/caps';
import {
iosCaps, serverConfig, SAUCE_TESTING, SAUCE_USERNAME, SAUCE_ACCESS_KEY
} from '../helpers/config';
const {assert} = chai;
describe('Create Safari session', function () {
it('should create and destroy IOS Safari session', async function () {
// Connect to Appium server
const driver = await wd.promiseChainRemote(serverConfig);
// Start the session
await driver.init({
...iosCaps,
browserName: 'Safari'
});
// Navigate to google.com
await driver.get('https://www.google.com');
// Test that it was successful by checking the document title
const pageTitle = await driver.title();
assert.equal(pageTitle, 'Google');
// Quit the session
await driver.quit();
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 Safari 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 Web Session Test',
}
: {};
// Start the session
await driver.init({
...iosCaps,
...sauceCaps,
browserName: 'Safari',
});
// Navigate to google.com
await driver.get('https://www.google.com');
// Test that it was successful by checking the document title
const pageTitle = await driver.title();
assert.equal(pageTitle, 'Google');
} finally {
// Quit the session, no matter what happens
await driver.quit();
}
});
});