Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions javascript/ integrated-android-web-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import 'babel-polyfill'
import 'colors'
import wd from 'wd'
import {assert} from 'chai'

const username = process.env.KOBITON_USERNAME
const apiKey = process.env.KOBITON_API_KEY
const deviceName = process.env.KOBITON_DEVICE_NAME || 'Galaxy*'
const udid = process.env.KOBITON_UDID

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',
udid: udid,
deviceGroup: 'KOBITON',
deviceName: deviceName,
platformName: 'Android'
}

let driver

if (!username || !apiKey) {
console.log('Error: Environment variables KOBITON_USERNAME and KOBITON_API_KEY are required to execute script')
process.exit(1)
}

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)
.keys(wd.SPECIAL_KEYS.Enter)

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}`)
}
}
})
})
1 change: 1 addition & 0 deletions javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ npm run multiple-devices-test
npm run jasmine-android-web-test
npm run jasmine-android-app-test
npm run integrate-with-testrail-test
npm run integrated-android-web-test
```

## VI. Report on Test Results
Expand Down
3 changes: 2 additions & 1 deletion javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"multiple-devices-test": "mocha --require babel-core/register --no-timeouts multiple-devices-test.js",
"jasmine-android-web-test": "./node_modules/jasmine/bin/jasmine.js ./spec/jasmine-android-web-spec.js",
"jasmine-android-app-test": "./node_modules/jasmine/bin/jasmine.js ./spec/jasmine-android-app-spec.js",
"integrate-with-testrail-test": "mocha --require babel-core/register --no-timeouts integrate-with-testrail-test.js"
"integrate-with-testrail-test": "mocha --require babel-core/register --no-timeouts integrate-with-testrail-test.js",
"integrated-android-web-test": "mocha --require babel-core/register --no-timeouts integrated-android-web-test.js"
},
"keywords": [
"kobiton",
Expand Down