question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress does not open color input on click

See original GitHub issue

Current behavior:

Color palette does not appear when click input type="color" in Cypress test. However it appears when click manually in browser launched by Cypress.

Desired behavior:

Color palette appears when click at input type="color"

Test code to reproduce

https://github.com/mayenok/cypress-test-tiny

Versions

Cypress: 4.9.0 Ubuntu 18.04.4 64-bit Chromium 83.0.4103.61

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
nitsancommented, Jan 31, 2021

Also work for Angular!

cy.get('input[type=color]')
    .invoke('val', '#ff0000')
    .trigger('input')
6reactions
EtienneBruinescommented, Jan 28, 2021

This workaround does not work for Vue, where the value gets overwritten as soon as Vue updates the view.

cy.get('input[type=color]')
    .invoke('val', '#ff0000')
    .trigger('change')

The addition of blur did not help in this case.

cy.get('input[type=color]')
    .click()
    .invoke('val', '#ff0000')
    .trigger('change')
    .blur()

The color is updated (visually), but gets overwritten as soon as Vue updates. This happens for example when someone clicks a (submit) button.


<input v-model="primaryColor"
       type="color">

TL;DR: What does work, is triggering an input Event for Vue.

cy.get('input[type=color]')
    .invoke('val', '#ff0000')
    .trigger('input')
Read more comments on GitHub >

github_iconTop Results From Across the Web

cypress-io/cypress - Gitter
Cypress testing cannot get the color change of the button but manual way of hovering ... cy.get('input[type=submit]') .click() cy.get('[data-test=error]') ...
Read more >
Cypress Assert color - Stack Overflow
1 Answer 1 · gives following error:invoke . · Do you have more than one path in your web page ? · i...
Read more >
focus - Cypress Documentation
Cypress blurs other focused elements first​​ If there is currently a different DOM element with focus, Cypress issues a blur event to that...
Read more >
Actions | Cypress examples (v9.4.1) - Gleb Bahmutov
Examples of actions being performed on DOM elements in Cypress, ... The element will need to be visible and actionable for .click to...
Read more >
HTMLInputElement.showPicker() - Web APIs | MDN
Click the button next to each input type to show its picker. showPicker() for a datalist input. showPicker() can launch the picker for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found