mardi 17 mars 2020

Can't select an option from a dropdown (autocomplete component) using cypress

I'm a beginner in cypress. I'm doing a test of an autocomplete component.

The problem is: when I want to select an option from the dropdown, it shows me any option. When I did the test manually there are options but with cypress no. It worked and after no.

I couldn't see the problem. Does anyone know how to do it please? (In cypress it didn't show in error)

Thanks,

Here the code of the autocomplete in js file

<Autocomplete
  id={"name-label-" + label.customId}
  options={options}
  getOptionLabel={option => (option && option.name ? option.name : "")}
  noOptionsText="No hay opciones"
  renderInput={params => (
    <TextField {...params} label="Selecciona el nombre de etiqueta" fullWidth />
  )}
  data-cy="fichaSelectname"
  onChange={(event, value) => handleOptionChange(event, value)}
  value={option}
  classes={classesAutocomplete}
/>;

And here's the cypress code I used

cy.get('[data-cy=fichaSelectname]').click().type('{downarrow}').type('{enter}');  

Aucun commentaire:

Enregistrer un commentaire