Skip to content

Commit

Permalink
Merge pull request #38 from Mr0grog/prepare-v1.1
Browse files Browse the repository at this point in the history
Version 1.1
  • Loading branch information
Mr0grog authored Mar 26, 2018
2 parents 12a39ab + 3ef7b8a commit 0e58bd6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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)

[#32]: https://github.com/Mr0grog/nightmare-real-mouse/pull/32
[#36]: https://github.com/Mr0grog/nightmare-real-mouse/pull/36
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -15,6 +15,10 @@
"input"
],
"author": "Rob Brackett <rob@robbrackett.com>",
"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"
Expand Down

0 comments on commit 0e58bd6

Please sign in to comment.