Open brian-mann opened 7 years ago
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.
๐๐๐
Sent from my iPhone
On Oct 26, 2017, at 18:56, Brian Mann notifications@github.com wrote:
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.
โ You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
good news, sounds exciting! ๐
Awesome! Is it devtools compatible? Do you plan to eventually deprecate the not-native commands?
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.
Does this mean we'll able to invoke and test :hover
/:active
pseudo classes?
Yes
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.
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.
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
@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.
@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
@egucciar yes, that page is a bit outdated now. I wouldn't say it's really native events per-se, we've known about them and tapped into the early parts of them for awhile, it has to do with the underlying architectural model and the proxy layer that cypress sits in.
There are a handful of things that all together will improve that and mean that Cypress will be a bit more transparent so your application behaves more closely to how it operates outside of Cypress. It's a bit like the uncertainty principle that by inspecting and viewing "the truth" of what happens in the browser in order to model and predict it, we thereby end up changing its behavior. Performance testing bit further outside-in than how Cypress operates, and because of that, our presence changes the behavior.
It is certainly possible for us to change even that - because the tools already exist, but it's more of a documentation / process problem for us. We're really good at one thing, and attempting to do too many things (even those closely related) is difficult while also maintaining a clear and specific objective.
@brian-mann appreciate the detailed explanation! So in short though this may open up the possibility of further integrations, some use cases still may not be applicable due to the overall architecture, performance testing being one of those things. Makes perfect sense.
Updates: along with native events, this goes hand in hand with cross browser support, which I added an update for here: https://github.com/cypress-io/cypress/issues/310#issue-191595673
TLDR; we are adding cross browser support as a major priority here. Work has been going on for months and we're ready to begin implementation.
@bahmutov ready for Sprint 5 or postpone ?
Here are my thoughts from approximately Nov 2018
Brian Thoughts:
active
elements or references...requestAnimationFrame
await
those timers before continuing on. This is ideal, but its a scalpel and it may be a whack-a-mole of edge cases, which brings us to #2Summary:
To summarize the above: what we're doing is adding a reconciliation phase
that awaits enqueued asynchronous functions (below a certain threshold) to fire in response to mutative events
that we fire as part of our dispatching and actionability algorithms. This will ensure that JS app code "receives" the events and that the DOM is updated in response to those (if necessary). We are not awaiting subsequent async functions like network requests
that happen as a side effect. Only DOM will be truly awaited in response to event handler callbacks (whether those JS app handlers are invoked synchronously or asynchronously).
Update:
If nested async handlers are called (such as a recursive setTimeout
) or requestAnimationFrame
- since those are wrapped and known to be in response to the awaited original async handlers, we simply continue to aggregate time until a certain threshold is met: 100ms
or 200ms
or something configurable. At that time (or at such time that we discern that the DOM has flushed appropriately) we will no longer await nested functions. To be clear though, only timers and animation frames will be awaited, not things like network request.
Another idea, possibly even easier would be to listen to DOM mutation events, and to always flush at that time irrespective of the nested async calls if we find that it's a more reliable way to know whether or not we can move on.
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.
Are we able to use this already with the latest cypress @brian-mann ?
Any word on when we can trigger copy/paste? https://github.com/cypress-io/cypress/issues/2386 ?
Thanks for the hard work!! I'm excited for this to come to fruition!
I was taking some notes about the missing things in the tool, but I'm not sure what of the following are in progress in the roadmap:
In some cases it's necessary to switch between those elements in order to validate if the new page opened load successfully (or to interact with the HTML elements). Some months ago, a lot of sites had the old way to authenticate a user using the Google API for login, and this opened a new window to set the login credentials of the user.
By the way, nice tool!
@WiseBird I updated my comment
For our current project, this is a major issue for our test coverages compared to using selenium. While I totally see other issue in the road map as important as well, do we have a timeline when this feature will be available?
For our current project, this is a major issue for our test coverages compared to using selenium. While I totally see other issue in the road map as important as well, do we have a timeline when this feature will be available?
I totally agree, I really do love Cypress solution very much. But as it is now, and for what I've tested it, I didn't be able to really use it to implement e2e testing on an existing product without facing continuous bugs due to the ways events are handled. I've identified two bottleneck when trying to implements tests who came to me over and over:
As stated in numerous issues related to this one, e2e testing should be as close as possible to the final user behavior. Cypress have a really great interface and debugging environment which is really good sugar when your writing tests. But the way is behave is, for now, too far from the 'real user way' that WebDrivers (or even library like puppeteer) simulate. Making it really difficult to achieve 80% e2e tests coverage on an existing product with it.
So, I will also be really interested to know when this feature is planned, and if anything can be done by the community to contribute to it.
Piling onto this mega-ticket: It'd be really great if Cypress fired the beforeInput
event for cy.type
. Without beforeinput
support, my team is blocked from adopting Cypress as we use the Slate.js contenteditable library.
beforeinput is not fired even though it is in the spec because no browser has adopted it.
The above isn't true... Chrome, Edge and Safari have all implemented the spec and Firefox is well on their way.
@kilrain Hopefully the Cypress team will update their input commands to dispatch the beforeinput event, but until they do Iโve created a couple of simple custom commands which will trigger Slateโs input event listeners and make it respond https://github.com/ianstormtaylor/slate/issues/3476#issuecomment-617594068
I saw this item being taken down from cypress road map page. Does that mean this item is not going to be brought up anytime soon?
@devtreehouse Having native browser events support is not in current development. It is still part of our future roadmap.
We updated our published roadmap to reflect what is in active development - not necessarily every feature we plan to do in the future, but we intend to improve upon this communication in the coming months.
@jennifer-shehane if Cypress exposed Chrome Devtools Protocol API (as suggested in https://github.com/cypress-io/cypress/issues/5670#issuecomment-552980964), then we could implement something in userland.
Published a package that implements native events using CDP connection (via cypress.automation
hook). This should be a great start for native events at cypress ๐ฃ.
For those that found themselves here looking for a solution: https://github.com/Bkucera/cypress-plugin-tab
@moritzWa it is not a real native browser event, so it won't work as a real browser tab. In order to make a real tab event use https://github.com/dmtrKovalenko/cypress-real-events and cy.realPress("Tab")
@dmtrKovalenko - Do cypress-real-events has support for drag and drop?
Would also really love this feature. Using cypress to test accessibility is not practical without native events.
Also: i cannot believe cypress not using native events isn't mentioned in the docs. There are several places where this should be made more clear. Eg. the page about cy.type. That page gives the impression you can emulate user behaviour, but for a11y purposes that's not true. I cannot select a label / button / link and type enter ... then get consistent results. See this ticket for more info.
@Badlapje your second link is the same as the first :)
fixed it, thx @beaugunderson !
Any progress on this? The minLength validation for <input>
tag still cannot be triggered in Cypress 6.1
Mostly all native events are implemented at https://github.com/dmtrKovalenko/cypress-real-events
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.
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.
In what version cy.type('{tab}') is supported? @eventualbuddha
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
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.
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. :(
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
click
IE11
without causing side effectscy.body().type()
:blur
focused element, send events tobody
.rightClick()
:new:possible:
click('left')
orclick('topleft')
:warning:not fixed:
type
[x] by default issues native events
[x]
force:true
skips actionability and uses simulated keys[ ] simulated keys have no delay :warning: change from 50ms
[x] native keys by default have no delay :warning: change from 50ms
[x] support new special
.type()
sequences:{moveToEnd}
,{moveToStart}
:new:[x] support new special
.type()
sequences:{tab}
,{shift+tab}
:new:[x] type follows focus :warning:
[x] trusted native keyboard events :new:
{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)focus
.focus
behavior on certain text editable elementscontenteditable
{moveToEnd}
/{moveToStart}
{tab}
file uploads :new:
cy.hover :new:
scroll behavior
Considerations / Research
select text command? :new:
mouse state
~for mouse actions that involve mouse state:~
For IE11 & firefox, see branch issue-311-ie-ff