From dcfa244287ffdda59b108b39de4c165f0232e7a6 Mon Sep 17 00:00:00 2001 From: arjunpatel17 <37914906+arjunpatel17@users.noreply.github.com> Date: Sun, 18 Apr 2021 20:35:59 -0400 Subject: [PATCH 1/6] add realActive() command --- README.md | 23 ++++ cypress/fixtures/frame-two.html | 1 + cypress/integration/active.spec.ts | 169 +++++++++++++++++++++++++++++ src/commands/realActive.ts | 53 +++++++++ src/index.d.ts | 10 ++ src/support.ts | 2 + 6 files changed, 258 insertions(+) create mode 100644 cypress/integration/active.spec.ts create mode 100644 src/commands/realActive.ts diff --git a/README.md b/README.md index 08ee03f..a9d848b 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Here is a simple test that can be written with native events: ```js it("tests real events", () => { + cy.get("input").realActive(); // perform a native mouse press on the field cy.get("input").realClick(); // perform a native real click on the field cy.realType("cypress real event"); // fires native system keypress events and fills the field cy.realPress("Tab"); // native tab click switches the focus @@ -74,6 +75,7 @@ If you are using typescript, also add the following to `cypress/tsconfig.json` The idea of the commands – they should be as similar as possible to cypress default commands (like `cy.type`), but starts with `real` – `cy.realType`. Here is an overview of the available **real** event commands: +- [cy.realActive](#cyrealactive) - [cy.realClick](#cyrealclick) - [cy.realHover](#cyrealhover) - [cy.realPress](#cyrealpress) @@ -81,6 +83,27 @@ Here is an overview of the available **real** event commands: - [cy.realType](#cyrealtype) - [cy.realSwipe](#cyrealswipe) +## cy.realActive + +Fires native system mouse press event. + +```jsx +cy.get("button").realActive(); +cy.get("button").realActive(options); +``` + +Example: + +```js +cy.get("button").realActive({ position: "topLeft" }) // click on the top left corner of button +``` + +Options: + +- `Optional` **pointer**: \"mouse\" \| \"pen\" +- `Optional` **position**: "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight" +- `Optional` **scrollBehavior**: "center" | "top" | "bottom" | "nearest" | false + ## cy.realClick Fires native system click event. diff --git a/cypress/fixtures/frame-two.html b/cypress/fixtures/frame-two.html index ec56d21..49eb036 100644 --- a/cypress/fixtures/frame-two.html +++ b/cypress/fixtures/frame-two.html @@ -13,6 +13,7 @@