spectron-window

0.0.3 • Public • Published

spectron-window

Installation

npm install --save-dev spectron-window

Usage

import SpectronWindow from 'spectron-window'
 
export default class Login extends SpectronWindow {
  // require
  get path () {
    return 'login.html'
  }
 
  username (val) {
    if (val) {
      return this.browser.setValue('#username', val)
    } else {
      return this.browser.getValue('#username')
    }
  }
 
  password (val) {
    if (val) {
      return this.browser.setValue('#password', val)
    } else {
      return this.browser.getValue('#password')
    }
  }
 
  async login (u, p) {
    await this.username(u)
    await this.password(p)
    return this.submit()
  }
 
  async submit () {
    await this.click('#login-btn')
  }
 
  //...
}
const Application = require('spectron').Application
const app = new Application({
  path: '....',
  startTimeout: 15000,
  quitTimeout: 10000,
  waitTimeout: 20000
})
await app.start()
await app.client.waitUntilWindowLoaded()
 
 
const loginWin = new LoginWin(app)

check full demo spectron-window-demo

Properties

browser

wrap spectron.client, but auto foucs window.

API

focus()

  • focus to window

isExist()

  • check the window isExist

License

MIT

Package Sidebar

Install

npm i spectron-window

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

109 kB

Total Files

9

Last publish

Collaborators

  • smildlzj