Last active
June 6, 2016 12:06
-
-
Save mario8x/88e6fd73c7924f2ef31002c992a3db13 to your computer and use it in GitHub Desktop.
Can't load module babel-polypill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Page from './page' | |
import DevicesPage from './devices' | |
const defaultElements = { | |
usernameTxt: '#app form input[name="emailOrUsername"]', | |
passwordTxt: '#app form input[name="password"]', | |
loginBtn: '#app form button', | |
profileBtn: '//*[@id="app"]/div/div[1]/div/div[2]/div[1]/div[2]/div/div[2]/button' | |
} | |
export default class LoginPage extends Page { | |
constructor(elements = {}) { | |
const totalElements = {...defaultElements, ...elements} | |
super(totalElements) | |
} | |
/** | |
* This function return true/fasle to let user know the current | |
* page logged in or not | |
*/ | |
async checkLoginStatus() { | |
try { | |
await this.client.waitForExist(this.elements.spinner) | |
await this.client.waitForExist(this.elements.profileBtn) | |
return true | |
} | |
catch (err) { | |
return false | |
} | |
} | |
async login(username, password) { | |
const check = await this.checkLoginStatus() | |
console.log('checkLoginStatus:' + check) | |
if (check === false) { | |
await this.client | |
.waitForExist(this.elements.usernameTxt) | |
.clearElement(this.elements.usernameTxt) | |
.setValue(this.elements.usernameTxt, username) | |
.setValue(this.elements.passwordTxt, password) | |
.click(this.elements.loginBtn) | |
.click(this.elements.loginBtn) | |
} | |
return new DevicesPage() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {desktopApp} from '../../helpers/setup' | |
import {killKobitonApp} from '../../helpers/exec' | |
const defaultElements = { | |
spinner: 'div.spinner-wrapper' | |
} | |
export default class Page { | |
constructor(elements = {}) { | |
this._elements = {...defaultElements, ...elements} | |
} | |
get elements() { | |
return this._elements | |
} | |
get client() { | |
return desktopApp.client | |
} | |
async startApplication() { | |
await desktopApp.start() | |
await this.client.waitUntilWindowLoaded() | |
} | |
async stopApplication() { | |
if (!desktopApp || !desktopApp.isRunning()) return | |
await desktopApp.stop() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const desktopApp = initDesktop() | |
function getDesktopPath() { | |
return (process.platform === 'win32') | |
? 'C:/Program Files/Kobiton/Kobiton.exe' : '/Applications/Kobiton\ 2.app/Contents/MacOS/Kobiton' | |
} | |
function initDesktop(options = {}) { | |
options.path = getDesktopPath() | |
options.startTimeout = 3000 | |
options.waitTimeout = 120000 | |
return new Application(options) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import LoginPage from './page-objects/login' | |
import {getAccount} from '../helpers/user-info' | |
describe('Verify desktop application', () => { | |
let loginPage | |
let devicesPage | |
before(async () => { | |
loginPage = new LoginPage() | |
await loginPage.startApplication() | |
}) | |
after(async () => { | |
await loginPage.stopApplication() | |
}) | |
it('should login successfully', async () => { | |
const account = getAccount() | |
await loginPage.login(account.emailOrUsername, account.password) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment