Need private packages and team management tools?Check out npm Teams »

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

Install

npm i spectron-window

DownloadsWeekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

109 kB

Total Files

9

Last publish

Collaborators

  • avatar