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

Function proceedSee

lib/helper/WebDriver.js:2951–2983  ·  view source on GitHub ↗
(assertType, text, context, strict = false)

Source from the content-addressed store, hash-verified

2949}
2950
2951async function proceedSee(assertType, text, context, strict = false) {
2952 let description
2953 if (!context) {
2954 if (this.context === webRoot) {
2955 context = this.context
2956 description = 'web page'
2957 } else {
2958 description = `current context ${this.context}`
2959 context = './/*'
2960 }
2961 } else {
2962 description = `element ${context}`
2963 }
2964
2965 const smartWaitEnabled = assertType === 'assert'
2966 const res = await this._locate(withStrictLocator(context), smartWaitEnabled)
2967 assertElementExists(res, context)
2968 let selected = await forEachAsync(res, async el => this.browser.getElementText(getElementId(el)))
2969
2970 // apply ignoreCase option
2971 if (store?.currentStep?.opts?.ignoreCase === true) {
2972 text = text.toLowerCase()
2973 selected = selected.map(elText => elText.toLowerCase())
2974 }
2975
2976 if (strict) {
2977 if (Array.isArray(selected) && selected.length !== 0) {
2978 return selected.map(elText => equals(description)[assertType](text, elText))
2979 }
2980 return equals(description)[assertType](text, selected)
2981 }
2982 return stringIncludes(description)[assertType](text, selected)
2983}
2984
2985/**
2986 * Mimic Array.forEach() API, but with an async callback function.

Callers

nothing calls this directly

Calls 6

equalsFunction · 0.90
withStrictLocatorFunction · 0.85
forEachAsyncFunction · 0.85
getElementIdFunction · 0.85
assertElementExistsFunction · 0.70
_locateMethod · 0.45

Tested by

no test coverage detected