-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
27 lines (23 loc) · 997 Bytes
/
index.ts
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
import {Ptor} from "protractor";
export default class AddCustomLocators {
static addDataTestId(protractor: Ptor) {
protractor.by.addLocator('dataTestId',
function (expected, parentElement: HTMLElement | null) {
let using = parentElement || document;
let nodes = using.querySelectorAll('[data-test-id]');
return Array.prototype.filter.call(nodes, function (node) {
return (node.getAttribute('data-test-id') === expected);
});
});
};
static addDataReactId(protractor: Ptor) {
protractor.by.addLocator('dataReactId',
function (expected, parentElement: HTMLElement | null) {
let using = parentElement || document;
let nodes = using.querySelectorAll('[data-reactid]');
return Array.prototype.filter.call(nodes, function (node) {
return (node.getAttribute('data-reactid') === expected);
});
});
};
}