Skip to content
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

Support for Native Browser Events #311

Open
14 of 25 tasks
brian-mann opened this issue Nov 24, 2016 · 45 comments
Open
14 of 25 tasks

Support for Native Browser Events #311

brian-mann opened this issue Nov 24, 2016 · 45 comments
Labels
Epic Requires breaking up into smaller issues pkg/driver This is due to an issue in the packages/driver directory topic: native events topic: rightclick 🖱 type: feature New feature that does not currently exist

Comments

@brian-mann
Copy link
Member

brian-mann commented Nov 24, 2016

click

  • simulated click fixes [moved] Simulated click fixes  #2956
  • on text-editable click in center move the cursor to the end
    • ensure possible in IE11 without causing side effects
  • cy.body().type():
    • blur focused element, send events to body
  • support .rightClick() 🆕

possible:

  • move cursor to beginning if click('left') or click('topleft') ⚠️

not fixed:

type

  • by default issues native events
  • force:true skips actionability and uses simulated keys
  • simulated keys have no delay ⚠️ change from 50ms
  • native keys by default have no delay ⚠️ change from 50ms
  • support new special .type() sequences: {moveToEnd},{moveToStart} 🆕
  • support new special .type() sequences: {tab},{shift+tab} 🆕
  • type follows focus ⚠️
  • trusted native keyboard events 🆕
{moveToEnd}/{moveToStart}
  • IE: setSelectionRange on all inputs
  • chrome/ff: setSelectionRange except for email/number inputs. For those we use execCommand('selectAll') + selection.modify('...')
  • branch logic based on browserFeatures object. For ex)
{
  setSelectionRangeOnAllInputTypes: true
}

focus

contenteditable

  • treated as any other text-editable in the commands above.
  • By default move cursor to end
  • support {moveToEnd}/{moveToStart}
  • support {tab}

file uploads 🆕

cy.hover 🆕

scroll behavior

  • scroll into view only if needed ⚠️
    • use getElementFromPoint on the pixel needing click
  • scroll into center by default ⚠️
  • allow user to configure scroll position (center, bottom, top) Enable users to change the scrolling strategy Enable users to change the scrolling strategy #871 🆕
    For IE:
    • scrollIntoView can't center, so calculate coords and try to center it manually

Considerations / Research

select text command? 🆕

  • allow user to make arbitrary text selection

mouse state

  • tbd

for mouse actions that involve mouse state:

  • in open mode, warn if potentially affected test
  • includes click (since hover before click), hover, drag-and-drop

For IE11 & firefox, see branch issue-311-ie-ff

@brian-mann brian-mann added the type: feature New feature that does not currently exist label Nov 24, 2016
@jennifer-shehane jennifer-shehane added stage: proposal 💡 No work has been done of this issue and removed roadmap labels Sep 25, 2017
@brian-mann
Copy link
Member Author

With the release of Chrome 63 we can now finally do this.

We'll begin by adding { native: true } to existing commands for users to opt into using the native variants of them.

From there we'll add new commands for file uploads, etc.

We can also expose a low level command for talking directly to the debugger protocol to expose all of the other power and goodness that extends well beyond WebDriver.

@bahmutov
Copy link
Contributor

bahmutov commented Oct 26, 2017 via email

@mateatslc
Copy link

good news, sounds exciting! 👏

@dziamid
Copy link

dziamid commented Nov 2, 2017

Awesome! Is it devtools compatible? Do you plan to eventually deprecate the not-native commands?

@brian-mann
Copy link
Member Author

It is dev tools compatible.

We will definitely not ever deprecate the non-native commands because they are actually more precise (as long as they work correctly). Non native can be issued synchronously and it's impossible to miss coordinates.

Native events will always be async, so if we ask for them to fire at a specific coordinate, it will take take before it's actually issued. If there are state changes by then - you have a failure.

We'll likely have a few native commands only like .attach() or something. But then enable you to opt into the native commands for commands we already have.

@dwelle
Copy link

dwelle commented Nov 4, 2017

Does this mean we'll able to invoke and test :hover/:active pseudo classes?

@brian-mann
Copy link
Member Author

Yes

@jennifer-shehane jennifer-shehane added the Epic Requires breaking up into smaller issues label Nov 27, 2017
@zth
Copy link

zth commented Jan 17, 2018

Is there a plan to integrate file uploading better with native events landing? There's a comment about it here cut I cannot seem to find any more information about it.

@atomboulian
Copy link

My question is the same as @zth. Seems like this would be true, but I just want to confirm. There are medium articles talking about file uploads not being supported, even in February of this year.

@jpike88
Copy link

jpike88 commented Jun 2, 2018

Just curious where things are at? I can't get a good reading on how close this functionality is to being ready or if it is already available

@brian-mann
Copy link
Member Author

@bkucera is starting on this work this week. We've gone through the game plan and will begin implementing this and all of the other work orthogonal to native events.

@jennifer-shehane jennifer-shehane added stage: in progress and removed Epic Requires breaking up into smaller issues stage: proposal 💡 No work has been done of this issue labels Jun 12, 2018
@egucciar
Copy link
Contributor

@brian-mann will this change some of the known "permanent limitations" of Cypress? One example being something like performance testing, which with integration with Dev Tools could totally be within reach

@laerteneto
Copy link

laerteneto commented Feb 26, 2021

Hey guys, do we have some updates on this? I am curious to see when we will get this natively implemented.
https://github.com/dmtrKovalenko/cypress-real-events looks very interesting indeed.

@jennifer-shehane
Copy link
Member

Check our roadmap for what we're currently working on. We're working on some larger features now, but this isn't one of them unfortunately.

We suggest using https://github.com/dmtrKovalenko/cypress-real-events in the meantime.

@ronit15
Copy link

ronit15 commented Sep 16, 2021

In what version cy.type('{tab}') is supported? @eventualbuddha

@hg13190
Copy link

hg13190 commented Dec 1, 2021

For interacting with native elements while using cypress I have used a work around via which I was able to achieve it, by running tests in headed mode (or via cypress runner) and robotjs.
Email me on hag13190@gmail.com to discuss details

@mryellow
Copy link

An interim release which delivers tab support would probably be a good idea. Leaving such a critical feature which has been demanded for 6 years hanging while other things are added is non-ideal.

@gyurielf
Copy link

An interim release which delivers tab support would probably be a good idea. Leaving such a critical feature which has been demanded for 6 years hanging while other things are added is non-ideal.

And it's still actual. :(

@rkrisztian
Copy link

I recently heard about WebDriver BiDi aiming to become the future of cross-browser automation, and it's something Cypress might want to consider for future implementation of native events. As we know, CDP was not really made for testing, and we're lucky that it's also supported in Firefox. But if for example, we want to support other browsers like Safari, then CDP won't be enough. (Plus, I also think that native events reflect more reliably what a real user does, and I find more value in realistic testing, but with the super handy UI of Cypress.)

I know that Cypress does not want to be Selenium, however they do not want to compete with other tools but rather collaborate with them. For more info please see: https://youtu.be/lpWwcWsyjQs?t=1310

@MikeMcC399
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic Requires breaking up into smaller issues pkg/driver This is due to an issue in the packages/driver directory topic: native events topic: rightclick 🖱 type: feature New feature that does not currently exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.