forked from testdouble/cypress-capybara
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
61 lines (60 loc) · 2.11 KB
/
index.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
54
55
56
57
58
59
60
61
const logCommand = require("./lib/log-command");
const buildCommand = require("./lib/build-command");
const stringTemplates = require("./lib/string-templates");
module.exports = {
commands: [
logCommand,
buildCommand({
name: "findLink",
type: "finder",
locatorTemplate: stringTemplates.css`
a[id="${"locator"}"],
a:contains("${"locator"}"),
*[data-heart-component=link]:contains("${"locator"}")
`,
}),
buildCommand({
name: "findField",
type: "finder",
locatorTemplate: stringTemplates.css`
input[type!=submit][type!=image][type!=hidden][id="${"locator"}"],
input[type!=submit][type!=image][type!=hidden][name="${"locator"}"],
input[type!=submit][type!=image][type!=hidden][placeholder="${"locator"}"],
textarea[id="${"locator"}"],
textarea[name="${"locator"}"],
select[id="${"locator"}"],
select[name="${"locator"}"],
label:contains("${"locator"}")
`,
labelTemplate: stringTemplates.css`
input[id="${"id"}"],
textarea[id="${"id"}"],
select[id="${"id"}"]
`,
}),
buildCommand({
name: "findButton",
type: "finder",
locatorTemplate: stringTemplates.css`
button:contains("${"locator"}"),
button[id="${"locator"}"],
button[title*="${"locator"}"],
input[type=submit][title*="${"locator"}"],
input[type=submit][value*="${"locator"}"],
input[type=submit][id="${"locator"}"],
input[type=reset][title*="${"locator"}"],
input[type=reset][value*="${"locator"}"],
input[type=reset][id="${"locator"}"],
input[type=image][title*="${"locator"}"],
input[type=image][value*="${"locator"}"],
input[type=image][alt*="${"locator"}"],
input[type=image][id="${"locator"}"],
input[type=button][title*="${"locator"}"],
input[type=button][value*="${"locator"}"],
input[type=button][id="${"locator"}"],
*[role=button]:contains("${"locator"}"),
*[data-heart-component=button]:contains("${"locator"}")
`,
}),
],
};