Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/helpers/Nightmare.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,14 @@ Can submit special keys like 'Enter', 'Backspace', etc

- `key`

## triggerMouseEvent

Sends [input event](http://electron.atom.io/docs/api/web-contents/#contentssendinputeventevent) on a page.

**Parameters**

- `event` event object, must contain `x` and `y` keys, others as needed from above link

## resizeWindow

Resize the current window to provided width and height.
Expand Down
24 changes: 24 additions & 0 deletions lib/helper/Nightmare.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ class Nightmare extends Helper {
}, function (key, done) {
this.child.call('pressKey', key, done);
});

this.Nightmare.action('triggerMouseEvent', function (ns, options, parent, win, renderer, done) {
parent.respondTo('triggerMouseEvent', function (evt, done) {
win.webContents.sendInputEvent(evt);
done();
});
done();
}, function (event, done) {
this.child.call('triggerMouseEvent', event, done);
});
}

_beforeSuite() {
Expand Down Expand Up @@ -567,6 +577,20 @@ class Nightmare extends Helper {
return this.browser.pressKey(key).wait(this.options.waitForAction);
}

/**
* Sends [input event](http://electron.atom.io/docs/api/web-contents/#contentssendinputeventevent) on a page.
* Should be a mouse event like:
* {
type: 'mouseDown',
x: args.x,
y: args.y,
button: "left"
}
*/
triggerMouseEvent(event) {
return this.browser.triggerMouseEvent(event).wait(this.options.waitForAction);
}

/**
* {{> ../webapi/seeCheckboxIsChecked }}
*/
Expand Down
1 change: 1 addition & 0 deletions translations/it-IT.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
'selectOption': 'seleziono_la_opzione',
'fillField': 'compilo_il_campo',
'pressKey': 'premo_il_tasto',
'triggerMouseEvent': 'attivare_levento_del_mouse',
'attachFile': 'allego_il_file',
'seeInField': 'vedo_nel_campo',
'dontSeeInField': 'non_vedo_nel_campo',
Expand Down
1 change: 1 addition & 0 deletions translations/pl-PL.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
'selectOption': 'wybieram_opcję',
'fillField': 'wypełniam_pole',
'pressKey': 'naciskam_przycisk',
'triggerMouseEvent': 'wywołaj_wydarzenie_myszki',
'attachFile': 'załączam_plik',
'seeInField': 'widzę_w_polu',
'dontSeeInField': 'nie_widzę_w_polu',
Expand Down
1 change: 1 addition & 0 deletions translations/pt-BR.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = {
'selectOption': 'selecionoAOpcao',
'fillField': 'preenchoOCampo',
'pressKey': 'pressioneATecla',
'triggerMouseEvent': 'lançarEventoDoMouse',
'attachFile': 'anexaOArquivo',
'seeInField': 'vejoNoCampo',
'dontSeeInField': 'naoVejoNoCampo',
Expand Down
1 change: 1 addition & 0 deletions translations/ru-RU.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
'selectOption': 'выбираю_опцию',
'fillField': 'заполнаю_поле',
'pressKey': 'нажимаю_кнопку',
'triggerMouseEvent': 'триггерное_событие_мыши',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, with all the translations! 🥇

'attachFile': 'загружаю_файл',
'seeInField': 'вижу_в_поле',
'dontSeeInField': 'не_вижу_в_поле',
Expand Down