(assertType, field, value, context)
| 3096 | } |
| 3097 | |
| 3098 | async function proceedSeeField(assertType, field, value, context) { |
| 3099 | const res = await findFields.call(this, field, context) |
| 3100 | assertElementExists(res, field, 'Field') |
| 3101 | const elem = usingFirstElement(res) |
| 3102 | const elemId = getElementId(elem) |
| 3103 | |
| 3104 | const proceedMultiple = async fields => { |
| 3105 | const fieldResults = toArray( |
| 3106 | await forEachAsync(fields, async el => { |
| 3107 | const elementId = getElementId(el) |
| 3108 | return this.browser.getElementAttribute(elementId, 'value') |
| 3109 | }), |
| 3110 | ) |
| 3111 | |
| 3112 | if (typeof value === 'boolean') { |
| 3113 | equals(`no. of items matching > 0: ${field}`)[assertType](value, !!fieldResults.length) |
| 3114 | } else { |
| 3115 | // Assert that results were found so the forEach assert does not silently pass |
| 3116 | equals(`no. of items matching > 0: ${field}`)[assertType](true, !!fieldResults.length) |
| 3117 | fieldResults.forEach(val => stringIncludes(`fields by ${field}`)[assertType](value, val)) |
| 3118 | } |
| 3119 | } |
| 3120 | |
| 3121 | const proceedSingle = async el => { |
| 3122 | let res = await el.getValue() |
| 3123 | |
| 3124 | if (res === null) { |
| 3125 | res = await el.getText() |
| 3126 | } |
| 3127 | |
| 3128 | if (res === null || res === undefined) { |
| 3129 | throw new Error(`Element ${el.selector} has no value attribute`) |
| 3130 | } |
| 3131 | |
| 3132 | stringIncludes(`fields by ${field}`)[assertType](value, res) |
| 3133 | } |
| 3134 | |
| 3135 | const filterBySelected = async elements => filterAsync(elements, async el => this.browser.isElementSelected(getElementId(el))) |
| 3136 | |
| 3137 | const filterSelectedByValue = async (elements, value) => { |
| 3138 | return filterAsync(elements, async el => { |
| 3139 | const elementId = getElementId(el) |
| 3140 | const currentValue = await this.browser.getElementAttribute(elementId, 'value') |
| 3141 | const isSelected = await this.browser.isElementSelected(elementId) |
| 3142 | return currentValue === value && isSelected |
| 3143 | }) |
| 3144 | } |
| 3145 | |
| 3146 | const tag = await elem.getTagName() |
| 3147 | if (tag === 'select') { |
| 3148 | let subOptions |
| 3149 | |
| 3150 | try { |
| 3151 | subOptions = await this.browser.findElementsFromElement(elemId, 'css', 'option') |
| 3152 | } catch (e) { |
| 3153 | subOptions = await this.browser.findElementsFromElement(elemId, 'xpath', 'option') |
| 3154 | } |
| 3155 |
nothing calls this directly
no test coverage detected