Skip to content

Instantly share code, notes, and snippets.

@nilswloka
Last active February 1, 2017 23:36
Show Gist options
  • Save nilswloka/1ba5ae100187ce1a6e741a471cb36348 to your computer and use it in GitHub Desktop.
Save nilswloka/1ba5ae100187ce1a6e741a471cb36348 to your computer and use it in GitHub Desktop.
Example for writing appium specs that can run locally and on BuddyBuild via Testdroid.
#!/usr/bin/env bash
export APK_FILE="$BUDDYBUILD_WORKSPACE/android/app/build/outputs/apk/app-release.apk"
echo "Uploading $APK_FILE"
export TESTDROID_FILE=`curl -s --user $TESTDROID_API: -F myAppFile=@$APK_FILE http://appium.testdroid.com/upload | node -pe "JSON.parse(require('fs').readFileSync('/dev/stdin').toString()).value.uploads.myAppFile"`
echo "Uploaded as $TESTDROID_FILE"
npm run functional-test
import wd from 'wd'
describe('Example App', function () {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 300000
var driver
beforeAll(function () {
var config, capabilities
if (process.env.TESTDROID) {
capabilities = {
platformName: 'Android',
testdroid_target: 'Android',
deviceName: 'Android Device',
testdroid_apiKey: process.env.TESTDROID_API,
testdroid_testrun: 'BuddyBuild ' + process.env.BUDDYBUILD_BUILD_NUMBER,
testdroid_device: 'LG Google Nexus 5 6.0 -EU', // the exact device string as
testdroid_project: 'Example Project', // the exact project name as set up in your Bitbar project overview
testdroid_app: process.env.TESTDROID_FILE
}
driver = wd.promiseChainRemote('http://appium.testdroid.com/wd/hub')
} else {
config = {
host: 'localhost',
port: 4723
}
capabilities = {
platformName: 'Android',
deviceName: '5203e181e8f353df',
appPackage: 'com.example',
appActivity: '.MainActivity'
}
driver = wd.promiseChainRemote(config)
}
return driver.init(capabilities, function (error) { console.log(error) }).setImplicitWaitTimeout(15000).nodeify()
})
afterAll(function () {
return driver.quit()
});
it('should show page title', function () {
return driver.elementsByXPath('//android.widget.TextView').then(elements => {
return elements[0].text()
}).then(text => {
expect(text).to.be.equal('My Example App')
})
})
})
{
"preset": "jest-react-native",
"unmockedModulePathPatterns": [
"node_modules/react/",
"node_modules/enzyme/"
],
"testEnvironment": "jsdom",
"testPathIgnorePatterns": [
"<rootDir>/src/",
"<rootDir>/node_modules/"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment