few-hairdresser-35052
11/02/2022, 4:40 PMacceptable-hamburger-48790
11/02/2022, 5:05 PMfew-hairdresser-35052
11/02/2022, 5:06 PMsome-napkin-20070
11/02/2022, 6:40 PMfamous-analyst-30680
11/02/2022, 7:04 PMCypress.env
which is not pushed to Github. Any Suggestions on how I can get this to work without pushing my .env info?brave-dog-85706
11/02/2022, 7:24 PMbrave-dog-85706
11/02/2022, 7:25 PMbrave-dog-85706
11/02/2022, 7:25 PMstale-optician-85950
11/02/2022, 7:28 PMstale-optician-85950
11/02/2022, 10:38 PMenv
attribute with env vars) are useful docs.famous-analyst-30680
11/02/2022, 10:38 PMicy-alarm-88737
11/03/2022, 1:14 AMcy.get("span:contains('OK'):visible").click();
cy.contains("span:visible", "OK").click();
i understand that cy.get
will return all matching elements and cy.contains
will only return the first, but it must go deeper than that.
I found myself in a situation where there are two popup elements, each containing an "OK" button. one popup has display:none
and the other is visible. the cy.get() command works as you would expect, it clicks on the visible OK button. the second one fails, and returns an error that says "the selected element in not visible". if I add {force: true}
to the second case, we confirmed its clicking the OK button in the popup that has display:none
.
im failing to understand why cy.contains
is selecting the wrong button and cy.get
is selecting the right oneicy-alarm-88737
11/03/2022, 1:17 AMadorable-smartphone-87280
11/03/2022, 1:17 AMcy.get
styled like that.adorable-smartphone-87280
11/03/2022, 1:18 AMcy.get('span:visible').contains('OK').click();
adorable-smartphone-87280
11/03/2022, 1:18 AMicy-alarm-88737
11/03/2022, 1:20 AM":contains('text')"
format is definedicy-alarm-88737
11/03/2022, 1:20 AMcy.contains("span:visible", "OK")
is failingadorable-smartphone-87280
11/03/2022, 1:20 AMicy-alarm-88737
11/03/2022, 1:21 AMcy.contains("span:visible", "OK")
is the simplest & clearest way to select but its broken, (or at least not doing the thing i would expect)icy-alarm-88737
11/03/2022, 1:22 AMcy.get("span:contains('OK'):visible").click();
works, and I could leave it at that, but im trying to understand what the difference is hereicy-alarm-88737
11/03/2022, 1:22 AMicy-alarm-88737
11/03/2022, 1:23 AMadorable-smartphone-87280
11/03/2022, 1:23 AMcontains
works the way you think it does. It's not intended to be passed a selector, it's designed to look for inner text, a number, or a RegEx. https://docs.cypress.io/api/commands/contains#Syntaxadorable-smartphone-87280
11/03/2022, 1:24 AMadorable-smartphone-87280
11/03/2022, 1:24 AMadorable-smartphone-87280
11/03/2022, 1:28 AM.get
works with pseudo-selectors, but .contains
doesn't? That's the only thing I can think of.adorable-smartphone-87280
11/03/2022, 1:29 AMcy.contains("span", "OK")
work? It might be an issue only when you append the :visible
?icy-alarm-88737
11/03/2022, 1:31 AMcy.contains("span", "OK")
and cy.contains("OK")
fail in the same way as mentioned above. they select the first ok button that they find, which happens to be the wrong one, which has display:none
adorable-smartphone-87280
11/03/2022, 1:33 AMcontains
returns the first element found. My guess is that it doesn't accept the jquery pseudo-selector but I'm not sure why. Might be worth opening an issue on Github over it, if you want a dev response.