MCPcopy
hub / github.com/codeceptjs/CodeceptJS / checkFocusBeforePressKey

Function checkFocusBeforePressKey

lib/helper/extras/focusCheck.js:23–43  ·  view source on GitHub ↗
(helper, originalKey)

Source from the content-addressed store, hash-verified

21}
22
23export async function checkFocusBeforePressKey(helper, originalKey) {
24 if (!helper.options.strict && !store.debugMode) return
25 if (!Array.isArray(originalKey)) return
26
27 let hasCtrlOrMeta = false
28 let actionKey = null
29 for (const k of originalKey) {
30 if (MODIFIER_PATTERN.test(k)) {
31 hasCtrlOrMeta = true
32 } else {
33 actionKey = k
34 }
35 }
36 if (!hasCtrlOrMeta || !actionKey || !EDITING_KEYS.has(actionKey.toLowerCase())) return
37
38 if (!await isNoElementFocused(helper)) return
39
40 const message = `No element is in focus. Key combination with "${originalKey.join('+')}" may not work as expected. Use I.click() or I.focus() first.`
41 if (helper.options.strict) throw new NonFocusedType(message)
42 helper.debugSection('Warning', message)
43}

Callers 3

pressKeyMethod · 0.90
pressKeyMethod · 0.90
pressKeyMethod · 0.90

Calls 1

isNoElementFocusedFunction · 0.85

Tested by

no test coverage detected