https://cypress.io logo
HTML Elements appear invisible to Cypress
# i-need-help
s
I have a button that is tagged with the correct
data-cy
attribute, but when I run a test that clicks on this button, Cypress is unable to find it. Using a normal user action does click on the button and fire its event successfully, but Cypress is unable to. What's more is that using Cypress's element selector also does not reveal any information about the button, simply glossing over it as if it didn't exist. Is there a reason why Cypress is unable to find the button?
g
s
seems like it would work, but I have no transforms applied to my button
and if this was the issue, why can't the cypress selector grab the button?
@gray-kilobyte-89541
g
well, how can I tell without any code, any screenshots, any information about your page and element markup?
w
The best thing would be to post the code you are using to test and the DOM that Cypress is trying to find the button in. A guess based on what you’ve said so far is: does the button belong to to web component where it is part of the shadow dom? Some information on accessing the shadow dom is here: https://docs.cypress.io/api/commands/shadow But maybe it’s not this at all.
s
Copy code
<button
   type="button"
   data-cy="replybutton"
   on:click={() => {
        console.log('Clicked');
         reply = true;
    }}>Reply</button
>
ohhhhh
I see the problem here
My tag was misspelled in the test spec lol
im sorry guys
w
Oh don’t worry we have all been there 🙂
2 Views