-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
cy.select() not working properly if index is used #24739
Comments
Hi @HeshamMoneer. Thank you for logging this issue. This does seem to be breaking but only when you have exact same values on each option. Are there any unique values on the objects that you are using, that can be used for the |
Hi @ryanthemanuel , I am afraid not. The only unique values they have are the objects they contain, and all these objects are converted unfortunately to an identical string in the HTML. I tried to overwrite select method as follows Cypress.Commands.overwrite('select', (originalFn, subject, value, options) => {
if(typeof value == 'number'){
return cy.wrap(subject).children('option').eq(value).then(e => {
return originalFn(subject, e.text().trim(), options);
});
}
else{
return originalFn(subject, value, options);
}
}); and it is working perfectly in other cases. However, my new command fails in this case as well since I have 2 options with the same string value (cairo). So I was wondering maybe if there is another workaround or something to use the option index to actually select it? |
Tracked this down in our driver code - we have logic to force the proper element in some cases, but it wasn't triggering here. Fix in #25016. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
I am running this command on the HTML element described above
The selected option should be "Frankfurt," however, "AHA Bug bash" is the selected option.
I believe this generally happens because of the value attribute that is identical for all options (because this problem does not happen when the value options are different). I, unfortunately, cannot change the values because they contain actual objects (that are interpreted in the HTML as the string "[object Object]").
I was hoping to select with an index value that won't be affected by the value attribute.
Desired behavior
The selected option should be "Frankfurt."
Test code to reproduce
Cypress Version
10.7.0
Node version
12.22.9
Operating System
Ubuntu 22.04.1 LTS
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: