forked from webdriverio/webdriverio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webdriverio.multiremote.chat.js
53 lines (44 loc) · 1.76 KB
/
webdriverio.multiremote.chat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Multiremote example
* To run this script you need to have Mocha installed globally on your system.
* If not try to run: $ npm install -g mocha
*
* To execute it just run it as a spec with a fair amount of timeout:
* $ mocha -t 9999999 examples/webdriverio.multiremote.chat.js
*/
var WebdriverIO = require('../'),
matrix = WebdriverIO.multiremote({
browserA: { desiredCapabilities: { browserName: 'chrome' } },
browserB: { desiredCapabilities: { browserName: 'chrome' } }
}),
browserA = matrix.select('browserA'),
browserB = matrix.select('browserB');
describe('multiremote example', function() {
it('should open chat application', function() {
return matrix.init().url('http://chat.socket.io/');
});
it('should login the browser', function(done) {
browserA.setValue('.usernameInput', 'Browser A');
browserB.setValue('.usernameInput', 'Browser B');
return matrix.sync().call(done);
});
it('should submit the login form', function() {
return matrix.keys('Enter');
});
it('should post something in browserA', function() {
return browserA
.setValue('.inputMessage', 'Hey Whats up!').pause(1000).keys('Enter').pause(100)
.setValue('.inputMessage', 'My name is Edgar').keys('Enter');
});
it('should read the message in browserB', function() {
return browserB
.pause(200)
.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');
});
});
it('should end the session', function() {
return matrix.pause(2000).end();
});
});