Merge pull request #5575 from electron/link-to-spectron
Add spectron to ChromeDriver doc
This commit is contained in:
commit
5368da18ad
1 changed files with 44 additions and 4 deletions
|
@ -8,8 +8,45 @@ 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 ChromeDriver.
|
||||||
|
|
||||||
|
```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
|
||||||
|
|
||||||
|
@ -21,7 +58,8 @@ a Node package for testing with web driver, we will use it as an example.
|
||||||
First you need to download the `chromedriver` binary, and run it:
|
First you need to download the `chromedriver` binary, and run it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ ./chromedriver
|
$ npm install electron-chromedriver
|
||||||
|
$ ./node_modules/.bin/chromedriver
|
||||||
Starting ChromeDriver (v2.10.291558) on port 9515
|
Starting ChromeDriver (v2.10.291558) on port 9515
|
||||||
Only local connections are allowed.
|
Only local connections are allowed.
|
||||||
```
|
```
|
||||||
|
@ -77,7 +115,8 @@ driver.
|
||||||
First you need to download the `chromedriver` binary, and run it:
|
First you need to download the `chromedriver` binary, and run it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ chromedriver --url-base=wd/hub --port=9515
|
$ npm install electron-chromedriver
|
||||||
|
$ ./node_modules/.bin/chromedriver --url-base=wd/hub --port=9515
|
||||||
Starting ChromeDriver (v2.10.291558) on port 9515
|
Starting ChromeDriver (v2.10.291558) on port 9515
|
||||||
Only local connections are allowed.
|
Only local connections are allowed.
|
||||||
```
|
```
|
||||||
|
@ -130,3 +169,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