MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / constructor

Method constructor

lib/locator.js:15–63  ·  view source on GitHub ↗

* @param {CodeceptJS.LocatorOrString} locator * @param {string} [defaultType]

(locator, defaultType = '')

Source from the content-addressed store, hash-verified

13 * @param {string} [defaultType]
14 */
15 constructor(locator, defaultType = '') {
16 this.type = null
17 if (!locator) return
18
19 this.output = null
20
21 /**
22 * @private
23 * @type {boolean}
24 */
25 this.strict = false
26
27 if (typeof locator === 'object') {
28 if (locator.constructor.name === 'Locator') {
29 Object.assign(this, locator)
30 return
31 }
32
33 this.locator = locator
34 this.type = Object.keys(locator)[0]
35 this.value = locator[this.type]
36 this.strict = true
37
38 Locator.filters.forEach(f => f(locator, this))
39
40 return
41 }
42
43 // Try to parse JSON strings that look like objects
44 if (this.parsedJsonAsString(locator)) {
45 return
46 }
47
48 this.type = defaultType || 'fuzzy'
49 this.output = locator
50 this.value = locator
51
52 if (isCSS(locator)) {
53 this.type = 'css'
54 }
55 if (isXPath(locator)) {
56 this.type = 'xpath'
57 }
58 if (isShadow(locator)) {
59 this.type = 'shadow'
60 }
61
62 Locator.filters.forEach(f => f(locator, this))
63 }
64
65 simplify() {
66 if (this.isNull()) return null

Callers

nothing calls this directly

Calls 4

parsedJsonAsStringMethod · 0.95
isCSSFunction · 0.85
isXPathFunction · 0.85
isShadowFunction · 0.85

Tested by

no test coverage detected