* {{> seeAttributesOnElements }} *
(locator, attributes)
| 2840 | * |
| 2841 | */ |
| 2842 | async seeAttributesOnElements(locator, attributes) { |
| 2843 | const res = await this._locate(locator) |
| 2844 | assertElementExists(res, locator) |
| 2845 | |
| 2846 | const elemAmount = res.length |
| 2847 | const commands = [] |
| 2848 | res.forEach(el => { |
| 2849 | Object.keys(attributes).forEach(prop => { |
| 2850 | commands.push(el.evaluate((el, attr) => el[attr] || el.getAttribute(attr), prop)) |
| 2851 | }) |
| 2852 | }) |
| 2853 | let attrs = await Promise.all(commands) |
| 2854 | const values = Object.keys(attributes).map(key => attributes[key]) |
| 2855 | if (!Array.isArray(attrs)) attrs = [attrs] |
| 2856 | let chunked = chunkArray(attrs, values.length) |
| 2857 | chunked = chunked.filter(val => { |
| 2858 | for (let i = 0; i < val.length; ++i) { |
| 2859 | // the attribute could be a boolean |
| 2860 | if (typeof val[i] === 'boolean') return val[i] === values[i] |
| 2861 | // if the attribute doesn't exist, returns false as well |
| 2862 | if (!val[i] || !val[i].includes(values[i])) return false |
| 2863 | } |
| 2864 | return true |
| 2865 | }) |
| 2866 | return equals(`all elements (${new Locator(locator)}) to have attributes ${JSON.stringify(attributes)}`).assert(chunked.length, elemAmount) |
| 2867 | } |
| 2868 | |
| 2869 | /** |
| 2870 | * {{> dragSlider }} |
nothing calls this directly
no test coverage detected