New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
select(); does not work on a select box of type select2 #26121
Comments
I tried to reproduce with a minimal example using select2, but it worked for me: /// <reference types="cypress" />
describe('page', () => {
it('works', () => {
cy.visit('https://select2.org/getting-started/basic-usage')
cy.get('.js-example-basic-single').select('California', { force: true })
})
}) Your code looks fine to me. I wonder if it is related to some kind of dynamic/async rendering via your framework or view library. What is the rest of your stack? Can you provide a minimal GitHub repository demonstrating the issue, so I can debug a bit more locally? |
Hello thank you for your quick feedback, my stack is for the view: Handlebars (+bootstrap), for the back: Node.js (Mongodb for the database). I'm not authorized to provide you with a Github repository, I'm sorry about that. |
I've find a solution, I don't use data-e2e but I use the class of my tags as a selector (with the cypress selector), so I created a command with arguments that will test all the select2 in my project. Here is what worked for me: `// In my support/command.js : I created a command that takes two arguments : Cypress.Commands.add('select2', (position, type) => {
}); `
I hope this will help devs who can't get cypress to work with a select2. I am French, so I apologize for my English, I hope I was understandable :) |
Glad you found a solution - this should "just work" (like in the example I showed). If you are able to make a minimal repo one day, happy to take a look. Until then, I don't know if I can do much else around Cypress and select2, so I'll close this one. |
Current behavior
I am testing a form that I need to fill in, there are two selects in this form. I manage to select the first but Cypress refuses to select the second. I also regularly have problems with select2, very often Cypress does not recognize them and therefore my tests do not pass.
It's not a problem of use because I never have problems with the classic "select", I know how to test them with Cypress. But I want to point out that Cypress has an unstable behavior with select2
Desired behavior
Desired behavior is for Cypress to recognize select2 values
Test code to reproduce
my test :
Mon user-data.js :
my inspector:
and my views :
Cypress Version
12.5.1
Node version
16.9.1
Operating System
Windows 11
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: