Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Electron + WebDriver = Spectron

Linda_pp
June 09, 2016

Electron + WebDriver = Spectron

Introduction to Spectron; a E2E testing framework for Electron apps

Linda_pp

June 09, 2016
Tweet

More Decks by Linda_pp

Other Decks in Technology

Transcript

  1. &MFDUSPO $ISPNJVN 4QFDUSPO XFCESJWFSJP :PVS5FTU $PEF :PVS"QQ w DBQBCJMJUZࣗಈࢦఆ w

    ESJWFSΦϒδΣΫ τ֦ு w 8FC%SJWFS"1* WJBDISPNFESJWFS w NPDIB΍BWBͳͲ Ͱςετ w &MFDUSPO"1*ͷϦ Ϟʔτ࣮ߦ
  2. import test from 'ava'; import {Application} from 'spectron'; test.beforeEach(async t

    => { t.context.app = new Application({ path: '/Applications/MyApp.app/Contents/MacOS/MyApp' }); await t.context.app.start(); }); test.afterEach.always(async t => { await t.context.app.stop(); }); test(async t => { const app = t.context.app; const client = app.client; await client.waitUntilWindowLoaded(); // Electron API (BrowserWindow) const win = app.browserWindow; t.true(await win.isVisible()); // Operate app via WebDriver await client.element('#name-input').keys('my name'); await client.click('#submit-btn'); t.true(await client.waitForExist('#login-success')); });
  3. FMFDUSPOQSFCVJMU ύοέʔδΛ࢖͍͍ͨ࣌ import {Application} from 'spectron'; import * as electron

    from 'electron-prebuilt'; test.beforeEach(async t => { t.context.app = new Application({ path: electron, args: ['/path/to/your/repository'], env: process.env, }); });
  4. HPUP'"*- w ςετ͕GBJMͨ͠ͱ͖ w NBJOϓϩηε΍SFOEFSFSϓϩηεͷϩάΛऩूͯ͠อ ଘ w DMJFOUHFU.BJO1SPDFTT-PHT  w

    DMJFOUHFU3FOEFS1SPDFTT-PHT  w DMJFOUDBQUVSF1BHF ͰεΫϦʔϯγϣοτอଘ w DMJFOUTBWF1BHF Ͱϖʔδͷ)5.-ςΩετΛอଘ