This repository was archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathinteractive_test.js
53 lines (43 loc) · 2.1 KB
/
interactive_test.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
var InteractiveTest = require('./interactive_test_util').InteractiveTest;
var port = 6969;
var test = new InteractiveTest('node lib/cli.js --elementExplorer true', port);
// Check state persists.
test.addCommandExpectation('var x = 3');
test.addCommandExpectation('x', '3');
// Check can return functions.
test.addCommandExpectation('var y = function(param) {return param;}');
test.addCommandExpectation('y', 'function (param) {return param;}');
// Check promises complete.
test.addCommandExpectation('browser.driver.getCurrentUrl()', 'data:,');
test.addCommandExpectation('browser.get("http://localhost:8081")');
test.addCommandExpectation('browser.getCurrentUrl()',
'http://localhost:8081/#/form');
// Check promises are resolved before being returned.
test.addCommandExpectation('var greetings = element(by.binding("greeting"))');
test.addCommandExpectation('greetings.getText()', 'Hiya');
// Check require is injected.
test.addCommandExpectation('var q = require("q")');
test.addCommandExpectation(
'var deferred = q.defer(); ' +
'setTimeout(function() {deferred.resolve(1)}, 100); ' +
'deferred.promise',
'1');
// Check errors are handled gracefully
test.addCommandExpectation('element(by.binding("nonexistent"))');
test.addCommandExpectation('element(by.binding("nonexistent")).getText()',
'ERROR: NoSuchElementError: No element found using locator: ' +
'by.binding("nonexistent")');
// Check global `list` works.
test.addCommandExpectation('list(by.binding("greeting"))', '[ \'Hiya\' ]');
test.addCommandExpectation('list(by.binding("nonexistent"))', '[]');
// Check complete calls
test.addCommandExpectation('\t',
'[["element(by.id(\'\'))","element(by.css(\'\'))",' +
'"element(by.name(\'\'))","element(by.binding(\'\'))",' +
'"element(by.xpath(\'\'))","element(by.tagName(\'\'))",' +
'"element(by.className(\'\'))"],""]');
test.addCommandExpectation('ele\t', '[["element"],"ele"]');
test.addCommandExpectation('br\t', '[["break","","browser"],"br"]');
// Make sure the global 'list' we added shows up.
test.addCommandExpectation('li\t', '[["list"],"li"]');
test.run();