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

Method seeCssPropertiesOnElements

lib/helper/Puppeteer.js:2087–2116  ·  view source on GitHub ↗

* {{> seeCssPropertiesOnElements }}

(locator, cssProperties)

Source from the content-addressed store, hash-verified

2085 * {{> seeCssPropertiesOnElements }}
2086 */
2087 async seeCssPropertiesOnElements(locator, cssProperties) {
2088 const res = await this._locate(locator)
2089 assertElementExists(res, locator)
2090
2091 const cssPropertiesCamelCase = convertCssPropertiesToCamelCase(cssProperties)
2092 const elemAmount = res.length
2093 let props = []
2094
2095 for (const element of res) {
2096 for (const prop of Object.keys(cssProperties)) {
2097 const cssProp = await this.grabCssPropertyFrom(locator, prop)
2098 if (isColorProperty(prop)) {
2099 props.push(convertColorToRGBA(cssProp))
2100 } else {
2101 props.push(cssProp)
2102 }
2103 }
2104 }
2105
2106 const values = Object.keys(cssPropertiesCamelCase).map(key => cssPropertiesCamelCase[key])
2107 if (!Array.isArray(props)) props = [props]
2108 let chunked = chunkArray(props, values.length)
2109 chunked = chunked.filter(val => {
2110 for (let i = 0; i < val.length; ++i) {
2111 if (val[i] != values[i]) return false
2112 }
2113 return true
2114 })
2115 return equals(`all elements (${new Locator(locator)}) to have CSS property ${JSON.stringify(cssProperties)}`).assert(chunked.length, elemAmount)
2116 }
2117
2118 /**
2119 * {{> seeAttributesOnElements }}

Callers 4

testsFunction · 0.45

Calls 11

_locateMethod · 0.95
grabCssPropertyFromMethod · 0.95
isColorPropertyFunction · 0.90
convertColorToRGBAFunction · 0.90
chunkArrayFunction · 0.90
equalsFunction · 0.90
pushMethod · 0.80
filterMethod · 0.80
assertMethod · 0.80
assertElementExistsFunction · 0.70

Tested by

no test coverage detected