Add spectron section
This commit is contained in:
parent
2043356fa3
commit
3f3871b1be
1 changed files with 41 additions and 2 deletions
|
@ -8,8 +8,46 @@ From [ChromeDriver - WebDriver for Chrome][chrome-driver]:
|
||||||
> implements WebDriver's wire protocol for Chromium. It is being developed by
|
> implements WebDriver's wire protocol for Chromium. It is being developed by
|
||||||
> members of the Chromium and WebDriver teams.
|
> members of the Chromium and WebDriver teams.
|
||||||
|
|
||||||
In order to use `chromedriver` with Electron you have to tell it where to
|
## Setting up Spectron
|
||||||
find Electron and make it think Electron is the Chrome browser.
|
|
||||||
|
[Spectron][spectron] is the officially supported ChromeDriver testing framework
|
||||||
|
for Electron. It is built on top of [WebdriverIO](http://webdriver.io/) and
|
||||||
|
has helpers to access Electron APIs in your tests and bundles the version
|
||||||
|
of ChromeDriver for Electron.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install --save-dev spectron
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
// A simple test to verify a visible window is opened with a title
|
||||||
|
var Application = require('spectron').Application
|
||||||
|
var assert = require('assert')
|
||||||
|
|
||||||
|
var app = new Application({
|
||||||
|
path: '/Applications/MyApp.app/Contents/MacOS/MyApp'
|
||||||
|
})
|
||||||
|
|
||||||
|
app.start().then(function () {
|
||||||
|
// Check if the window is visible
|
||||||
|
return app.browserWindow.isVisible()
|
||||||
|
}).then(function (isVisible) {
|
||||||
|
// Verify the window is visible
|
||||||
|
assert.equal(isVisible, true)
|
||||||
|
}).then(function () {
|
||||||
|
// Get the window's title
|
||||||
|
return app.client.getTitle()
|
||||||
|
}).then(function (title) {
|
||||||
|
// Verify the window's title
|
||||||
|
assert.equal(title, 'My App')
|
||||||
|
}).then(function () {
|
||||||
|
// Stop the application
|
||||||
|
return app.stop()
|
||||||
|
}).catch(function (error) {
|
||||||
|
// Log any failures
|
||||||
|
console.error('Test failed', error.message)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
## Setting up with WebDriverJs
|
## Setting up with WebDriverJs
|
||||||
|
|
||||||
|
@ -132,3 +170,4 @@ your app's folder. This eliminates the need to copy-paste your app into
|
||||||
Electron's resource directory.
|
Electron's resource directory.
|
||||||
|
|
||||||
[chrome-driver]: https://sites.google.com/a/chromium.org/chromedriver/
|
[chrome-driver]: https://sites.google.com/a/chromium.org/chromedriver/
|
||||||
|
[spectron]: http://electron.atom.io/spectron
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue