-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetValueSlow.js
42 lines (33 loc) · 1.05 KB
/
setValueSlow.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
var util = require('util');
var events = require('events');
function setValue() {
events.EventEmitter.call(this);
}
util.inherits(setValue, events.EventEmitter);
setValue.prototype.command = function(object, value) {
const self = this;
const api = this.client.api;
var selector = object;
if (typeof object === 'string') {
selector = object;
} else {
var element = object[object.length - 1];
selector = element.selector;
var container = element.parent;
while (container != null && container.selector != null && typeof container.selector == 'string' && container.selector != '')
{
selector = container.selector + ' ' + selector;
container = container.parent;
}
}
api.elements('css selector', selector, function (elems) {
elems.value.forEach(function (element) {
for (var c of value.split('')) {
api.elementIdValue(element.ELEMENT, c);
}
self.emit('complete');
});
});
return this;
};
module.exports = setValue;