{"action":"created","issue":{"url":"https://api.github.com/repos/segmentio/nightmare/issues/959","repository_url":"https://api.github.com/repos/segmentio/nightmare","labels_url":"https://api.github.com/repos/segmentio/nightmare/issues/959/labels{/name}","comments_url":"https://api.github.com/repos/segmentio/nightmare/issues/959/comments","events_url":"https://api.github.com/repos/segmentio/nightmare/issues/959/events","html_url":"https://github.com/segmentio/nightmare/issues/959","id":201066872,"number":959,"title":"Custom action dont works","user":{"login":"necromind","id":3032254,"avatar_url":"https://avatars.githubusercontent.com/u/3032254?v=3","gravatar_id":"","url":"https://api.github.com/users/necromind","html_url":"https://github.com/necromind","followers_url":"https://api.github.com/users/necromind/followers","following_url":"https://api.github.com/users/necromind/following{/other_user}","gists_url":"https://api.github.com/users/necromind/gists{/gist_id}","starred_url":"https://api.github.com/users/necromind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/necromind/subscriptions","organizations_url":"https://api.github.com/users/necromind/orgs","repos_url":"https://api.github.com/users/necromind/repos","events_url":"https://api.github.com/users/necromind/events{/privacy}","received_events_url":"https://api.github.com/users/necromind/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-16T16:37:59Z","updated_at":"2017-01-16T16:58:32Z","closed_at":null,"body":"Code from here: https://github.com/segmentio/nightmare/issues/887#issuecomment-269412280\r\n\r\n```js\r\nNightmare.action('sendKeyPress',\r\n  function(name, options, parent, win, renderer, done) {\r\n    parent.respondTo('sendKeyPress', function(unicodeValue, done) {\r\n      win.focus();\r\n      win.webContents.sendInputEvent({\r\n        type: \"keyDown\",\r\n        keyCode: unicodeValue,\r\n      });\r\n      setTimeout(() => {\r\n        win.webContents.sendInputEvent({\r\n          type: \"keyUp\",\r\n          keyCode: unicodeValue,\r\n        });\r\n        done();\r\n      },50);\r\n    });\r\n    done();\r\n  },\r\n  function(unicodeValue, done) {\r\n    this.child.call('sendKeyPress', unicodeValue, done);\r\n  });\r\n\r\n\tnightmare\r\n\t\t//.cookies.clearAll()\r\n\t\t.viewport(1280, 1024)\r\n\t\t.goto('https://url/')\r\n\t\t.sendKeyPress('\\u202D')\r\n\t\t.run();\r\n```\r\n\r\nAnd i have error: \r\n```\r\nreturn fn.apply(self, doneargs);\r\n             ^\r\nTypeError: Cannot read property 'apply' of undefined\r\n```\r\nWhy dont works? This is like example from main wiki \"Defining a custom action with an Electron method\""},"comment":{"url":"https://api.github.com/repos/segmentio/nightmare/issues/comments/272914542","html_url":"https://github.com/segmentio/nightmare/issues/959#issuecomment-272914542","issue_url":"https://api.github.com/repos/segmentio/nightmare/issues/959","id":272914542,"user":{"login":"necromind","id":3032254,"avatar_url":"https://avatars.githubusercontent.com/u/3032254?v=3","gravatar_id":"","url":"https://api.github.com/users/necromind","html_url":"https://github.com/necromind","followers_url":"https://api.github.com/users/necromind/followers","following_url":"https://api.github.com/users/necromind/following{/other_user}","gists_url":"https://api.github.com/users/necromind/gists{/gist_id}","starred_url":"https://api.github.com/users/necromind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/necromind/subscriptions","organizations_url":"https://api.github.com/users/necromind/orgs","repos_url":"https://api.github.com/users/necromind/repos","events_url":"https://api.github.com/users/necromind/events{/privacy}","received_events_url":"https://api.github.com/users/necromind/received_events","type":"User","site_admin":false},"created_at":"2017-01-16T16:58:32Z","updated_at":"2017-01-16T16:58:32Z","body":"Solved. done must be first: \r\n```js\r\n  function(done, unicodeValue) {\r\n    this.child.call('sendKeyPress', unicodeValue, done);\r\n  });\r\n```\r\n\r\nBut this code anyway dont send press right key event."}}
{"actor":{"display_login":"necromind"}}