-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPerfectoSpec.js
More file actions
65 lines (58 loc) · 2.01 KB
/
PerfectoSpec.js
File metadata and controls
65 lines (58 loc) · 2.01 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
var logger = console,
Perfecto = require('../lib/Perfecto').Perfecto, // Perfecto Main module
Conf = require('./ClientConf.js'), // Test configuration
client = new Perfecto.PerfectoClient(Conf.protocol ,Conf.host, Conf.user, Conf.pass), // Creating a client
deviceId = Conf.deviceId; // Import deviceId from the configuration file
describe("Test perfecto NodeJS RESTful API client", function() {
// Set Jasmine defualt timeout interval
jasmine.DEFAULT_TIMEOUT_INTERVAL = 40000;
// beforeEach creates new execution and open device
beforeEach(function(done) {
logger.log('========== Before Test ==========');
client.startNewExecution()
.then((execution_Id)=>{
return client.openDevice(deviceId);
})
.then((ans)=>{
done();
});
});
// afterEach closing the device and ends the execution
afterEach(function(done) {
logger.log('========== After Test ==========')
client.closeDevice()
.then((ans) =>{
// logger.log('Closing device status: ' + JSON.parse(ans)['description']);
return client.endExecution();
})
.then((ans) =>{
done();
});
});
// Test
it("Should search in google", function(done) {
logger.log('========== Test ==========');
client.browserOpen()
.then((ans)=>{
return client.browserGoTo('https://google.com');
})
.then((ans)=>{
return client.browserFindElement('name', 'q');
})
.then((ans)=>{
/**
* 'returnValue' contains the XPath of the returned element
* (if there's more then one returns an array of values)
*/
let elem = JSON.parse(ans).returnValue;
elem = elem.substring(1, elem.length - 1); // remove the '[' & ']' from the string
return client.browserSetElementValue('xpath', elem, 'Perfecto');
})
.then((ans)=>{
return client.browserElementClick('name', 'btnG');
})
.then((ans)=>{
done();
});
}); // end it
}); // end describe