Recently, I have been diving into learning Cypress and have spent the last few weeks automating different websites. However, I have encountered a challenge when trying to click a button based on its class or text value, which seems like it should be a simple task.
The button I am trying to interact with does not have an id and has a lengthy class name:
message-component message-button no-children focusable sp_choice_type_11 last-focusable-el
Refer to the image below for a visual of the complete element:
https://i.sstatic.net/sUrU8.jpg
Here are the different code snippets I have attempted:
cy.contains('Accept All').click()
cy.get('#message-component message-button no-children focusable sp_choice_type_11 last-focusable-el').contains('Accept All').click();
cy.get('button').contains('Accept All').click()
Unfortunately, none of the above approaches worked, and the button remains elusive.
I have referenced the Cypress documentation and even sought advice from a post on Stack Overflow:
Find by text content
I also considered the possibility that the button loads after a delay of four seconds, so I increased the
"defaultCommandTimeout"
to 7000. However, this adjustment did not bring about any success.
If anyone has any suggestions or ideas, they would be greatly appreciated!
*** EDIT ****
Error message screenshot:
https://i.sstatic.net/O3Rcn.png
Cypress popup screenshot: