interactors icon indicating copy to clipboard operation
interactors copied to clipboard

Allow to define array of locator functions as a interactor's locator

Open wKich opened this issue 3 years ago • 1 comments

For example, this is a locator of material-ui Button https://github.com/thefrontside/interactors/blob/6454cc6caccbd12303a2d4776f399385c0e47c09/packages/material-ui/src/button.ts#L10 As you can see, buttons can be located by aria-label attribute and by innerText. But the problem is if we have a button with both aria-label and innerText values, we can't find that button by innerText value, because our locator return the first value from aria-label attribute.

So I suggest to add ability to define an array of functions as locator. So locator could be look like this:

.locator([
  (element) => element.getAttribute("aria-label"),
  (element) => element.innerText
])

And then you can find your button by any of these possible ways.

wKich avatar Feb 16 '22 11:02 wKich

I'm off two minds on this. It sounds easier, but how often do you really want to have it be both? In the case of MUI what is the case where the inner text and the aria label are different (I'm guessing that there is, but just curious what it is)

cowboyd avatar Feb 28 '22 09:02 cowboyd