We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
focus
1 parent e313678 commit 2df4191Copy full SHA for 2df4191
Gruntfile.js
@@ -319,13 +319,24 @@ module.exports = function (grunt) {
319
value: '<div class="class" tabindex="0">Text</div>'
320
}
321
},
322
+ coverage ? { wait: 1 } : {
323
+ focus: 'body',
324
+ wait: function (browser) {
325
+ return browser.hasFocus('body')
326
+ .then(function (value) {
327
+ if (value !== false) {
328
+ throw new Error('focus on body failed')
329
+ }
330
+ })
331
332
+ },
333
{
- clickIfVisible: 'select',
334
+ clickIfVisible: 'input',
335
wait: function (browser) {
- return browser.hasFocus('select')
336
+ return browser.hasFocus('input')
337
.then(function (value) {
- if (value === false) {
- throw new Error('clickIfVisible on select failed')
338
339
+ throw new Error('clickIfVisible on invisible input failed')
340
341
})
342
tasks/html-dom-snapshot.js
@@ -8,10 +8,10 @@ const mkdirp = require('mkdirp')
8
// order in a command object. In this order they will be looked for and
9
// executed.
10
const instructionKeys = [
11
- 'setViewport', 'url', 'go', 'scroll', 'clearValue', 'setValue', 'addValue',
12
- 'selectOptionByIndex', 'selectOptionByValue', 'moveCursor',
13
- 'click', 'clickIfVisible', 'keys', 'wait', 'hasAttribute', 'hasClass', 'hasValue',
14
- 'hasText', 'hasInnerHtml', 'hasOuterHtml',
+ 'setViewport', 'url', 'go', 'scroll', 'focus', 'clearValue', 'setValue',
+ 'addValue', 'selectOptionByIndex', 'selectOptionByValue', 'moveCursor',
+ 'click', 'clickIfVisible', 'keys', 'wait', 'hasAttribute', 'hasClass',
+ 'hasValue', 'hasText', 'hasInnerHtml', 'hasOuterHtml',
15
'isEnabled', 'isExisting', 'isFocused', 'isSelected', 'isVisible',
16
'isVisibleWithinViewport', 'isNotEnabled', 'isNotExisting',
17
'isNotFocused', 'isNotSelected', 'isNotVisible',
tasks/instructions/focus.js
@@ -0,0 +1,30 @@
1
+'use strict'
2
+
3
+// Istanbul instruments the callback to be executed in the browser,
4
+// introduces variables there, which are defined only in the node
5
+// part of the code and thus breaks the code.
6
7
+/* istanbul ignore next */
+module.exports = {
+ detect: function (command) {
+ return !!command.focus
+ perform: function (grunt, target, client, command) {
+ const focus = command.focus
+ grunt.verbose.writeln('Focus "' + focus + '".')
+ return client.execute(function (selector) {
18
+ var element = document.querySelector(selector)
19
+ if (!element) {
20
+ return false
21
22
+ element.focus()
23
+ }, focus)
24
25
+ if (value === false) {
26
+ throw new Error('"' + focus + '" does not exist.')
27
28
29
30
+}
0 commit comments