garris / BackstopJS

Catch CSS curve balls.
http://backstopjs.org
MIT License
6.69k stars 604 forks source link

How to simulate keyboard navigation? #1411

Open Bagelwolf opened 2 years ago

Bagelwolf commented 2 years ago

I'm trying to test focus states, which are only triggered via keyboard navigation. Is there a way to simulate a tab or arrow keypress?

Tried seeing if submitting a keycode instead of a string would work; it doesn't.

{ "selector": ".testing-div", "keypress": 9 // JS keycode }

masi commented 2 years ago
scenarios: [
  {
    "keyPressSelectors": [
      {
        "selector": "#email",
        "keyPress": "marcdacz@backstopjs.com"
      },
      {
        "selector": "#password",
        "keyPress": "1234"
      }
    ]
  }
]
HaSistrunk commented 1 year ago

Seconding this as a really useful feature! Any chance to merge the open PR (https://github.com/garris/BackstopJS/pull/1176) that incorporates focus state testing functionality?