These are chat archives for rosshinkley/nightmare

4th
Dec 2016
Selwyn
@Siilwyn
Dec 04 2016 10:39
Hey there people :)
I'm very confused about using Nightmare.action to use Electron functionality... Anybody experience with this?
Nightmare.action('getWindowPosition',
  function(name, options, parent, win, renderer, done) {
    parent.respondTo('getWindowPosition', function (done) {
      parent.emit('log', `Window position: ${win.getPosition()}`);
      return win.getPosition();
      done();
    });
    done();
  },
  function(message, done) {
    // this.child.emit('log', 'test 123');
    this.child.call('getWindowPosition', done);
  });

Nightmare()
  .useragent(useragent)
  .goto('https://duckduckgo.com/')
  .getWindowPosition()
  .then(function (result) {
    // robot.moveMouseSmooth(498,345)
    console.log(result);
  })
  .catch(function (error) {
    console.error(error);
  });
I basically want to click on things in a 'human way' so I thought using RobotJS could help. Now the coordinates RobotJS uses are based on the screen, not the viewport... So to fix that I want to add the difference of the window position. :)
Selwyn
@Siilwyn
Dec 04 2016 11:03
parent.emit('log', Window position: ${win.getPosition()}); logs correctly but I can't get it to return the coordinates outside of that scope
Selwyn
@Siilwyn
Dec 04 2016 15:23
Also @rosshinkley it seems nightmare's repository has a lot of unlabeled open issues. Could I help cleaning it up?
JP
@JPHUNTER
Dec 04 2016 23:31
is Nightmare async?