These are chat archives for rosshinkley/nightmare

24th
May 2016
Amol
@amolc
May 24 2016 09:01
Hello Guys, can you help me how I can select an option and then press the submit button
<select name="ddlTOP" id="ddlTOP" class="form-control">
<option value="1960">1960</option>
<option value="1961">1961</option>
<option value="1962">1962</option> <input type="submit" name="btnSearchByTOP" value="Search" id="btnSearchByTOP" class="btn btn-small btn-primary">
I want to select an option and then submit it
Need help please
Ross Hinkley
@rosshinkley
May 24 2016 13:17
@amolc have you tried .select()?
nightmare
  .goto(myUrl)
  .select('#ddlTOP', '1962')
  .click('#btnSearchByTOP')
  .then(() => { console.log('done'); })
Ross Hinkley
@rosshinkley
May 24 2016 13:22
something like that
Amol
@amolc
May 24 2016 17:10
tried, somehow the submit isn't working.
Ross Hinkley
@rosshinkley
May 24 2016 17:13
not working ... how?
Ross Hinkley
@rosshinkley
May 24 2016 17:23
.wait() requires at least one argument, i think
Amol
@amolc
May 24 2016 17:25
checking
You can try to run the code
basically I am selecting a form
and it selects the year properly
but then the submit doesn't get clicked
@rosshinkley trying realClick now..
Ross Hinkley
@rosshinkley
May 24 2016 17:27
a good thing to try
still the search is not being clicked.. I have tried to set the "show = true" too
so you can visualise it
Ross Hinkley
@rosshinkley
May 24 2016 17:30
off the cuff, you'll want to move the realMouse call to before your nightmare constructor
i'm kind of shocked it's not bombing
the way you have it
still the same issue.
Ross Hinkley
@rosshinkley
May 24 2016 17:38
hmm...
running it with DEBUG, it looks like it spawns an internal server error
let me take another look at this when i get back to my desk
Ross Hinkley
@rosshinkley
May 24 2016 17:58
hm.... looks like the call to webContents.savePage() (which is what .html() calls) is interfering with the request
// tw.js
// Perfom a login and take a screenshot of the Twitter home of a user
'use strict';

const Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true })


nightmare
  .goto('http://www.housefly.com.sg/#bytop')
  .select('#ddlTOP', '2016')
  .click('#btnSearchByTOP')
  .wait('#sample_1')
  .html('./2017.html')
  .then(() => { console.log('done'); })
waiting for whatever roundtrip the server is in the middle of seems to solve it
Ross Hinkley
@rosshinkley
May 24 2016 18:09
i'm not sure what webContents.savePage() is doing to interfere, though.... i'd think it's passive
Ross Hinkley
@rosshinkley
May 24 2016 18:17
hhhhuh
i am wrong
savepage calls stop
:stars:
i think?
(took me a minute to find, i was looking at an older version of chromium, evidently)
Ross Hinkley
@rosshinkley
May 24 2016 18:38
at any rate, calling .html() is causing the request to get interrupted, causing the server to not respond appropriately, making it look like click() is not working