]> khamidou — GitHub mirrors - electron.git/commitdiff
Update using-selenium-and-webdriver.md
authorLeMoussel <cnhx27@gmail.com>
Fri, 21 Aug 2015 10:09:31 +0000 (12:09 +0200)
committerLeMoussel <cnhx27@gmail.com>
Fri, 21 Aug 2015 10:09:31 +0000 (12:09 +0200)
Add an example of how to use webdriverio with electron

docs/tutorial/using-selenium-and-webdriver.md

index 13934c01b0866b6de026be4b73d055975d25f7a6..29d95576227ecab0f65abd3a0c2e17162bdd6bdc 100644 (file)
@@ -70,6 +70,52 @@ driver.wait(function() {
 driver.quit();
 ```
 
+## Setting up with WebdriverIO
+
+[WebdriverIO](http://webdriver.io/) provided a Node package for testing with web driver.
+
+### 1. Start chrome driver
+
+First you need to download the `chromedriver` binary, and run it:
+
+```bash
+$ chromedriver --url-base=/wd/hub --port=9515
+Starting ChromeDriver (v2.10.291558) on port 9515
+Only local connections are allowed.
+```
+
+Remember the port number `9515`, which will be used later
+
+### 2. Install WebDriverJS
+
+```bash
+$ npm install webdriverio
+```
+
+### 3. Connect to chrome driver
+```javascript
+var webdriverio = require('webdriverio');
+var options = {
+       host: "localhost", // Use localhost as chrome driver server 
+    port: 9515,        // "9515" is the port opened by chrome driver.
+    desiredCapabilities: {
+            browserName: 'chrome',
+            chromeOptions: {binary: '/Path-to-Your-App.app/Electron'} // Path to your Electron binary.
+        }
+};
+
+webdriverio
+    .remote(options)
+    .init()
+    .url('http://google.com')
+    .setValue('#q', 'webdriverio')
+    .click('#btnG')
+    .title(function(err, res) {
+        console.log('Title was: ' + res.value);
+    })
+    .end();
+```
+
 ## Workflow
 
 To test your application without rebuilding Electron, simply [place](https://github.com/atom/electron/blob/master/docs/tutorial/application-distribution.md) your app source into Electron's resource directory.