Skip to content

Instantly share code, notes, and snippets.

@khanhdodang
Created December 20, 2017 08:44
Show Gist options
  • Save khanhdodang/1e0d7f6c8e9e48c870cdbeeb502facf0 to your computer and use it in GitHub Desktop.
Save khanhdodang/1e0d7f6c8e9e48c870cdbeeb502facf0 to your computer and use it in GitHub Desktop.
import 'babel-polyfill'
import 'colors'
import wd from 'wd'
import {assert} from 'chai'
const username = 'your Kobiton username'
const apiKey = 'your Kobiton api key'
const kobitonServerConfig = {
protocol: 'https',
host: 'api.kobiton.com',
auth: `${username}:${apiKey}`
}
const desiredCaps = {
sessionName: 'Automation test session',
sessionDescription: 'This is an example for Android web',
deviceOrientation: 'portrait',
captureScreenshots: true,
browserName: 'chrome',
deviceGroup: 'KOBITON',
deviceName: 'Galaxy',
platformName: 'Android'
}
let driver
describe('Android Web sample', () => {
before(async () => {
driver = wd.promiseChainRemote(kobitonServerConfig)
driver.on('status', (info) => {
console.log(info.cyan)
})
driver.on('command', (meth, path, data) => {
console.log(' > ' + meth.yellow, path.grey, data || '')
})
driver.on('http', (meth, path, data) => {
console.log(' > ' + meth.magenta, path, (data || '').grey)
})
try {
await driver.init(desiredCaps)
}
catch (err) {
if (err.data) {
console.error(`init driver: ${err.data}`)
}
throw err
}
})
it('should return the title that contains Kobiton', async () => {
await driver.get('https://www.google.com')
.waitForElementByName('q')
.sendKeys('Kobiton')
.sleep(3000)
.waitForElementByName('btnG')
.click()
let msg = await driver.title()
assert.include(msg, 'Kobiton - Google Search')
})
after(async () => {
if (driver != null) {
try {
await driver.quit()
}
catch (err) {
console.error(`quit driver: ${err}`)
}
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment