-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata.js
269 lines (266 loc) · 7.6 KB
/
data.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
var levels = [
{
instruction: "1. Select all titles",
helpTitle: "Select by tag",
selector: {
css: "h3"
},
helpText: "Selects all elements of type <strong>E</strong>. <strong>E</strong> refers to the type of element, for example: <strong><div></strong>, <strong><span></strong>. ",
examples: [
'CSS: E',
'XPath: //E',
],
html: `
<h3>Title 1</h3>
<p>Lorem ipsum dolor sit amet.</p>
<h3>Title 2</h3>
<p id="description">Consectetur adipiscing elit.</p>
`
},
{
instruction: "2. Select the description text",
helpTitle: "Select by id",
selector: {
css: "p#description"
},
helpText: "<strong>#id</strong> selects an element with a specific id. You can combine the id selector with the tag selector, resulting in <strong>E#id</strong>",
examples: [
'CSS: E#id',
'XPath: //E[@id = "id"]',
],
html: `
<h3>Title 1</h3>
<p>Lorem ipsum dolor sit amet.</p>
<h3>Title 2</h3>
<p id="description">Description text.</p>
`
},
{
instruction: "3. Select the active list item",
helpTitle: "Select by class",
selector: {
css: "li.active"
},
helpText: "<strong>.classname</strong> selects an element with a specific classname. You can combine the classname selector with the tag selector, resulting in <strong>E.classname</strong> When combining we are more precise.",
examples: [
'CSS: E.classname',
'XPath: //E[@class = "classname"]',
],
html: `
<ul>
<li>item 1</li>
<li class="active">item 2</li>
<li>item 3</li>
</ul>
`
},
{
instruction: "4. Select only the button which is part of the toolbar",
helpTitle: "Descendant Selector",
selector: {
css: "div#toolbar button"
},
helpText: "<strong>E1 E2</strong> selects all the <strong>E2</strong> elements which are inside of <strong>E1</strong> elements. <strong>E2</strong> is descendant, because it's inside another element.",
examples: [
'CSS: E1 E2',
'XPath: //E1/E2',
],
html: `
<p>Some text</p>
<div id="toolbar">
<button type="button">Edit</button>
</div>
<button type="button">Save</button>
`
},
{
instruction: "5. Select the first div",
helpTitle: "Select first of type",
selector: {
css: "div:first-of-type()"
},
helpText: "<strong>:first-of-type</strong> selects the first element of a specific type.",
examples: [
'CSS: E:first-of-type',
'XPath: //E[1]',
],
html: `
<div>First div</div>
<div>Second div</div>
`
},
{
instruction: "6. Select the last div",
helpTitle: "Select last of type",
selector: {
css: "div:last-of-type()"
},
helpText: "<strong>:last-of-type</strong> selects the last element of a specific type.",
examples: [
'CSS: E:last-of-type',
'XPath: //E[last()]',
],
html: `
<div>First div</div>
<div>Second div</div>
`
},
{
instruction: "7. Select the second element from the list",
helpTitle: "Select child elements",
selector: {
css: "ul > li:nth-child(2)"
},
helpText: "",
examples: [
'CSS: E:nth-child(2)',
'XPath: //*[2][name()="E"]',
],
html: `
<ul>
<li>Home</li>
<li>Categories</li>
<li>Faq</li>
<li>Contact</li>
</ul>
`
},
{
instruction: "8. Select element with text Oceans based on text",
helpTitle: "Select elements based on text",
selector: {
xpath: "//h4[text() = 'Oceans']"
},
helpText: "XPath's <strong>text()</strong> function can retrieve text from specific elements.",
examples: [
'CSS: n/a',
'XPath: //E[text() = "t"]',
],
html: `
<h4>Midnight</h4>
<h4>Another's Arms</h4>
<h4>Oceans</h4>
<h4>A Sky Full of Stars</h4>
`
},
{
instruction: "9. Select the nickname textfield",
helpTitle: "Select elements with attribute exactly containing value",
selector: {
css: "input[name='nickname']"
},
helpText: "<strong>E[a='v']</strong> selects all elements that have a specific attribute value.",
examples: [
'CSS: E[a="v"]',
'XPath: //E[@a="v"]',
],
html: `
<form>
<input name="j_id819:inputUsername" type="text" placeholder="username" />
<input name="nickname" type="text" placeholder="nickname" />
<input name="j_id819:inputEmail:j_id819" type="text" placeholder="email" />
<input name="password:j_id819" type="text" placeholder="password" />
</form>
`
},
{
instruction: "10. Select the username textfield",
helpTitle: "Select elements with attribute ending with value",
selector: {
css: "input[name$='inputUsername']"
},
helpText: "<strong>E[a='v']</strong> selects all elements ending with a attribute value.",
examples: [
'CSS: E[a$="v"]',
'XPath: //E[ends-with(@A, "v")]',
],
html: `
<form>
<input name="j_id819:inputUsername" type="text" placeholder="username" />
<input name="nickname" type="text" placeholder="nickname" />
<input name="j_id819:inputEmail:j_id819" type="text" placeholder="email" />
<input name="password:j_id819" type="text" placeholder="password" />
</form>
`
},
{
instruction: "11. Select the email textfield",
helpTitle: "Select elements with attribute exactly containing value",
selector: {
css: "input[name*='inputEmail']"
},
helpText: "<strong>E[a*='v']</strong> selects all elements that contain a specific attribute value.",
examples: [
'CSS: E[a*="v"]',
'XPath: //E[contains(@A, "v")]',
],
html: `
<form>
<input name="j_id819:inputUsername" type="text" placeholder="username" />
<input name="nickname" type="text" placeholder="nickname" />
<input name="j_id819:inputEmail:j_id819" type="text" placeholder="email" />
<input name="password:j_id819" type="text" placeholder="password" />
</form>
`
},
{
instruction: "12. Select the password textfield",
helpTitle: "Select elements with attribute starting with value",
selector: {
css: "input[name^='password']"
},
helpText: "<strong>E[a^='v']</strong> selects all elements starting with a attribute value.",
examples: [
'CSS: E[a^="v"]',
'XPath: //E[starts-with(@A, "v")]',
],
html: `
<form>
<input name="j_id819:inputUsername" type="text" placeholder="username" />
<input name="nickname" type="text" placeholder="nickname" />
<input name="j_id819:inputEmail:j_id819" type="text" placeholder="email" />
<input name="password:j_id819" type="text" placeholder="password" />
</form>
`
},
{
instruction: "13. Select the Edit button related to row 678",
helpTitle: "Walking up the DOM",
selector: {
xpath: "//td[contains(text(), '678')]/../td/button[@class = 'edit']"
},
helpText: "You can use the XPath 'magic' to walk up the DOM, like: /../",
examples: [
'CSS: n/a',
'XPath: //E1/../E2',
],
html: `
<table class="table table-bordered">
<tr>
<td>456</td>
<td>Description</td>
<td>€ 100,-</td>
<td><button class="edit">Edit</button><button class="delete">Delete</button></td>
</tr>
<tr>
<td>123</td>
<td>Description</td>
<td>€ 100,-</td>
<td><button class="edit">Edit</button><button class="delete">Delete</button></td>
</tr>
<tr>
<td>678</td>
<td>Description</td>
<td>€ 100,-</td>
<td><button class="edit">Edit</button><button class="delete">Delete</button></td>
</tr>
<tr>
<td>987</td>
<td>Description</td>
<td>€ 100,-</td>
<td><button class="edit">Edit</button><button class="delete">Delete</button></td>
</tr>
</table>
`
}
];