Skip to content

Commit

Permalink
update examples - closes #2087
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed May 27, 2017
1 parent 58ce564 commit 6c5004b
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 109 deletions.
3 changes: 1 addition & 2 deletions examples/cloudservices/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Cloudservices

Shows you how to use WebdriverIO using Sauce Labs, Browserstack or Testingbot. To run those tests make sure
you have your credentials stored in your environment. If so just execute the file using node:
Shows you how to use WebdriverIO using Sauce Labs, Browserstack or Testingbot. To run those tests make sure you have your credentials stored in your environment. If so just execute the file using node:

## webdriverio.saucelabs.js

Expand Down
11 changes: 6 additions & 5 deletions examples/cloudservices/webdriverio.browserstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ var webdriverio = require('../../build/index'),
}).init();

client
.url('http://google.com')
.setValue('*[name="q"]','webdriverio')
.click('*[name="btnG"]')
.url('http://webdriver.io')
.setValue('.ds-input', 'click')
.click('.algolia-docsearch-suggestion--title')
.pause(1000)
.getTitle().then((title) => {
console.log(title);
console.log(title); // should return "WebdriverIO - click"
})
.end();
.end()
.catch((e) => console.log(e));
11 changes: 6 additions & 5 deletions examples/cloudservices/webdriverio.saucelabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ var webdriverio = require('../../build/index'),
}).init();

client
.url('http://google.com')
.setValue('*[name="q"]','webdriverio')
.click('*[name="btnG"]')
.url('http://webdriver.io')
.setValue('.ds-input', 'click')
.click('.algolia-docsearch-suggestion--title')
.pause(1000)
.getTitle().then((title) => {
console.log(title);
console.log(title); // should return "WebdriverIO - click"
})
.end();
.end()
.catch((e) => console.log(e));
11 changes: 6 additions & 5 deletions examples/cloudservices/webdriverio.testingbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ var webdriverio = require('../../build/index'),
}).init();

client
.url('http://google.com')
.setValue('*[name="q"]','webdriverio')
.click('*[name="btnG"]')
.url('http://webdriver.io')
.setValue('.ds-input', 'click')
.click('.algolia-docsearch-suggestion--title')
.pause(1000)
.getTitle().then((title) => {
console.log(title);
console.log(title); // should return "WebdriverIO - click"
})
.end();
.end()
.catch((e) => console.log(e));
3 changes: 1 addition & 2 deletions examples/commands/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Commands

All files inside this directory demonstrate how some commands can get used. To run these examples just
execute them with node.
All files inside this directory demonstrate how some commands can get used. To run these examples just execute them with node.
10 changes: 10 additions & 0 deletions examples/commands/helpers/externalAddCommandHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
searchWebdriverIO: function (searchString) {
return this
.url('http://webdriver.io')
.setValue('.ds-input', searchString)
.pause(1000)
.keys(['Enter']) //press Enter Key
.pause(1000);
}
};
21 changes: 11 additions & 10 deletions examples/commands/webdriverio.addCommand.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
var webdriverio = require('../../build/index');
var helper = require('./webdriverio.externalAddCommandHelper');
var helper = require('./helpers/externalAddCommandHelper');

var options = {
var client = webdriverio.remote({
desiredCapabilities: {
browserName: 'chrome'
}
};
var client = webdriverio.remote(options);
client.addCommand('searchGoogle',helper.searchGoogle.bind(client));
});

var SearchString = 'webdriver.io';
client.addCommand('searchWebdriverIO', helper.searchWebdriverIO.bind(client));

var SearchString = 'click';

client
.init()
.searchGoogle(SearchString) //external helper function
.title(function(err, res) {
console.log('Title was: ' + res.value);
.searchWebdriverIO(SearchString) //external helper function
.getTitle().then(function(title) {
console.log('Title was: ' + title);
})
.end();
.end()
.catch((e) => console.log(e));
10 changes: 0 additions & 10 deletions examples/commands/webdriverio.externalAddCommandHelper.js

This file was deleted.

8 changes: 6 additions & 2 deletions examples/commands/webdriverio.selectBy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ client
.pause(2000)
.selectByIndex('select', 4)
.pause(2000)
.selectByValue('select', 'years/2009.html')
.selectByValue('select', '2009')
.pause(2000)
.selectByVisibleText('select', '2008')
.pause(2000)
.end();
.end()
.then(
() => console.log('WebdriverIO script ran successfully'),
(e) => console.log(e)
);
2 changes: 1 addition & 1 deletion examples/multiremote/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Run this test by executing the file using node. It opens up a WebRTC page with t
This example demonstrates how you could test a chat system. Both browser will connet to a text based chat. One browser will input something whereas the other browser reads the message, interprets it and returns with a proper response message. You can execute the test using Mocha. Make sure you pass a high timeout as argument to make the test work properly.

```sh
./node_modules/.bin/mocha ./examples/multiremote/webdriverio.multiremote.chat.js --timeout 9999999
./node_modules/.bin/mocha ./examples/multiremote/webdriverio.multiremote.chat.js
```
1 change: 1 addition & 0 deletions examples/multiremote/webdriverio.multiremote.chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('multiremote example', function() {
it('should read the message in browserB', function() {
return browserB
.pause(200)
.waitForExist('.messageBody*=My name is')
.getText('.messageBody*=My name is').then(function(message) {
var name = message.slice(11);
return browserB.setValue('.inputMessage', 'Hello ' + name + '! How are you today?').keys('Enter');
Expand Down
6 changes: 5 additions & 1 deletion examples/multiremote/webdriverio.multiremote.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ matrix
.url('https://apprtc.appspot.com/r/' + channel)
.click('#confirm-join-button')
.pause(5000)
.end();
.end()
.then(
() => console.log('Multiremote script ran successfully'),
(e) => console.log(e)
);
5 changes: 3 additions & 2 deletions examples/pageobject/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.config = {
// directory is where your package.json resides, so `wdio` will be called from there.
//
specs: [
'./specs/*.spec.js'
__dirname + '/specs/*.spec.js'
],
//
// ============
Expand Down Expand Up @@ -99,7 +99,8 @@ exports.config = {
// Options to be passed to Mocha.
// See the full list at http://mochajs.org/
mochaOpts: {
ui: 'bdd'
ui: 'bdd',
timeout: 30000
},
//
// =====
Expand Down
4 changes: 3 additions & 1 deletion examples/wdio/reporter/my.custom.reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ var CustomReporter = function(options) {
});
};

CustomReporter.reporterName = 'CustomReporter';

/**
* Inherit from EventEmitter
*/
Expand All @@ -57,4 +59,4 @@ util.inherits(CustomReporter, events.EventEmitter);
/**
* Expose Custom Reporter
*/
exports = module.exports = CustomReporter;
exports = module.exports = CustomReporter;
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Feature: Example feature

Scenario: Get title of website
Given I go on the website "https://github.com/"
Then should the title of the page be "How people build software · GitHub"
Then should the title of the page be "The world's leading software development platform · GitHub"
18 changes: 0 additions & 18 deletions examples/wdio/runner-specs/webdrivercss.js

This file was deleted.

2 changes: 1 addition & 1 deletion examples/wdio/wdio.multiremote.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ exports.config = {
logLevel: 'silent',
coloredLogs: true,
screenshotPath: 'shots',
baseUrl: 'http://chat.socket.io',
baseUrl: 'https://socketio-chat.now.sh',
waitforTimeout: 10000,
framework: 'mocha',

Expand Down
43 changes: 0 additions & 43 deletions examples/wdio/wdio.webdrivercss.conf.js

This file was deleted.

0 comments on commit 6c5004b

Please sign in to comment.