Await locator.waitFor(), a question about state within the parens

is this valid?
await locator.waitFor({ state: 'attached', state: 'visible' });

Does one also check for the other? I can’t tell from the documentation what each one also checks for, and the code, well, it’s not straight forward.

Example: does “visible” also validate “attached” state, or does it assume “attached”?

I can’t find any documentation indicates this nor can I find the logic path in the code, but maybe I’m just not scoping my searches properly in the k6 code base.

Any guidance would be appreciated.

Thanks!
Mike Poz

Hi @roadatlas,

{ state: 'attached', state: 'visible' } will not work (as you expect) as that will create an object that will have the value of state set twice, but it can only have one value.

The current k6 documentation is missing explanations on what the values mean, and I have opened an issue for that.

The playwright documentation though does explain them and the k6 browser one is based on it.

Given that attached means that it exists at all in the dom, it needs to be such in order to be visible. So I visible will also mean attached. In practice invisible means that it is also attached.

Hope this helps you!

Thank you for the response, I wanted to be sure. I looked at the playwright link you suggested and will move forward with an alternative implementation.

Mike Poz