From e18965efb6125a901dedb9b2fc646e40d7bbcd6a Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Sun, 25 Mar 2018 16:01:40 -0700 Subject: [PATCH 1/2] Update to v1.1, update docs, add contributor list --- CHANGELOG.md | 6 ++++++ README.md | 25 +++++++++++++++++++++---- package.json | 8 ++++++-- 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f9f5eda --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# Changelog + +## v1.1 (2018-03-25) + +- Support Nightmare v3 (#36) +- Add an argument for specifying the position of the mouse event (relative to the selected element). (#32 by @Zzzen) diff --git a/README.md b/README.md index 64759ab..100fdc8 100644 --- a/README.md +++ b/README.md @@ -52,22 +52,39 @@ require('nightmare-real-mouse')(Nightmare); The plugin provides three methods that are alternatives to those built into Nightmare: -### realClick(selector) + +### realClick(selector, [position]) Click on the element with the specified `selector`. Note that, because this is a real mouse event, the click won’t actually happen directly on the specified element if it is obscured by some other element (instead, it will happen on the element that is visually "in front"). -The actual location of the click will be the center of the specified element. +The actual location of the click can be specified with the second argument, `position`, which should be an object with `x` and `y` properties that are numbers. They represent offsets from the top/left corner of the element specified by `selector`. If unspecified, the position will be the center of the element. Issuing two `realClick()` calls within 300ms of each other on the same element will additionally trigger a `dblclick` event. -### realMouseover(selector) +**Example:** + +```js +// Click the top-left corner of the "I'm Feeling Lucky" button on Google +Nightmare() + .goto('https://google.com') + .realClick('input[value*="Lucky"]', {x: 1, y: 1}) + .then(() => console.log('Clicked “I’m Feeling Lucky!”')); +``` + + +### realMouseover(selector, [position]) Fires `mouseover` and `mouseenter` events on the given `selector`. This will also fire the relevant `mouseout` and `mouseleave` events on elements that the mouse was previously over, if any. -### realMousedown(selector) +Like `realClick()`, the optional `position` argument is an object with `x` and `y` properties specifying the location of the event inside the element. If unspecified, the location will be the center of the element. + + +### realMousedown(selector, [position]) Fires the `mousedown` event on the given `selector`. It will also cause `mouseover` and `mouseenter` events on the element and `mouseout` and `mouseleave` events on whatever element the mouse *was* over if the mouse is not already over the element. +Like `realClick()`, the optional `position` argument is an object with `x` and `y` properties specifying the location of the event inside the element. If unspecified, the location will be the center of the element. + ## License diff --git a/package.json b/package.json index 4ee244e..9baf924 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nightmare-real-mouse", - "version": "1.0.0", - "description": "A Nightmare plug-in for better mimicing true mouse events", + "version": "1.1.0", + "description": "A Nightmare plug-in for better mimicking true mouse events", "main": "index.js", "scripts": { "test": "mocha test" @@ -15,6 +15,10 @@ "input" ], "author": "Rob Brackett ", + "contributors": [ + {"name": "Rob Brackett", "email": "rob@robbrackett.com"}, + {"name": "@Zzzen", "url": "https://github.com/Zzzen"} + ], "license": "BSD-3-Clause", "bugs": { "url": "https://github.com/Mr0grog/nightmare-real-mouse/issues" From 3ef7b8a1caebf78453ccc44c8af5ddb6ad920df7 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Sun, 25 Mar 2018 16:39:41 -0700 Subject: [PATCH 2/2] Make changelog issue references into links --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9f5eda..40f2572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,5 +2,8 @@ ## v1.1 (2018-03-25) -- Support Nightmare v3 (#36) -- Add an argument for specifying the position of the mouse event (relative to the selected element). (#32 by @Zzzen) +- Support Nightmare v3 ([#36][]) +- Add an argument for specifying the position of the mouse event (relative to the selected element). ([#32][] by @Zzzen) + +[#32]: https://github.com/Mr0grog/nightmare-real-mouse/pull/32 +[#36]: https://github.com/Mr0grog/nightmare-real-mouse/pull/36