How to resize the textarea in Cypress.
I’m using cypress-real-events
plugin to interact with html elements.
I’ve to resize the textarea and tried below code but its not working.
cy.get("textarea").eq(0)
.realMouseDown({ position: "bottomRight" })
.realMouseUp({ position: "bottomRight" })
.realMouseDown({ position: "bottomRight" })
.realMouseMove(100, 100, { position: "bottomRight" })
.realMouseUp({ position: "bottomRight" });
2
Answers
I upgraded
cypress-real-events
to latest 1.8.1 version and usedrealMouseWheel
event to fixed it.Below is the code:
Although I tried yesterday to get a solution using javascript, I could not get any success.
I think that’s because the
textarea
is a control that is built into the browser and does not have correct hooks (methods or properties) to affect the sizing of the box.For example, I used a local HTML file which just has a
<textarea>
. Running local avoids the issues for which puneet had to addcy.wait(3000)
in between commands.With this local test, there is no asynchronous element and all the code takes effect immediately.
This is the failing test which relies on javascript.
Passing the test with CSS
The
<textarea>
can be resized with the browser CSS engine instead of javascript.