Getting a visible field by name
Next, we have to gather a collection of fields:
If (elements.length > 0 and elementType === "field"{ elements = await browser.$$(`//label[ normalize-space()='${element}']//preceding::input `) }
If there are no matches, we will take a second shot at finding text areas relative to a label:
If (fieldElements.length === 0 and elementType === "field"{ elements = await browser.$$(`//label[normalize-space()='${element}']//preceding::textarea`) }
Finally, we will do the same for a collection of lists.